QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#115711 | #5904. Twirling Towards Freedom | Zesty_Fox | 0 | 4727ms | 4244kb | C++20 | 2.3kb | 2023-06-26 16:46:17 | 2023-06-26 16:46:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using u32=unsigned int;
using i64=long long;
using u64=unsigned long long;
using db=double;
using vi=vector<int>;
using pii=pair<int,int>;
template<typename T>
T read(){
T x=0,f=0;char ch=getchar();
while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
while(isdigit(ch)) x=x*10+(ch-'0'),ch=getchar();
return f?-x:x;
}
#define rdi read<int>
#define rdi64 read<i64>
#define fi first
#define se second
#define pb push_back
const int N=5010,INF=0x3f3f3f3f,MX=2000;
int n,m;
pii p[N];
template<typename T>
void ckmin(T &a,T b){
if(a>b) a=b;
}
template<typename T>
void ckmax(T &a,T b){
if(a<b) a=b;
}
void solve(int tid){
n=rdi(),m=rdi();
for(int i=1;i<=n;i++){
int x=rdi(),y=rdi();
p[i]={x-y,x+y};
}
static int f[5][(MX+1)*8][2];
const int DT=MX*4;
f[0][0][0]=f[0][0][1]=0;
for(int i=1;i<=4;i++){
for(int k=-MX*i;k<=MX*i;k++)
f[i][k+DT][0]=INF,f[i][k+DT][1]=-INF;
for(int j=1;j<=n;j++){
int v1,v2;
if(i==1) v1=p[j].fi,v2=p[j].se;
else if(i==2) v1=p[j].se,v2=-p[j].fi;
else if(i==3) v1=-p[j].fi,v2=-p[j].se;
else if(i==4) v1=p[j].se,v2=p[j].fi;
for(int k=-MX*(i-1);k<=MX*(i-1);k++){
if(f[i-1][k+DT][0]==INF) continue;
ckmin(f[i][k+v1+DT][0],f[i-1][k+DT][0]+v2);
ckmax(f[i][k+v1+DT][1],f[i-1][k+DT][1]+v2);
}
}
}
auto dis2 = [&](i64 x,i64 y){
return (db)x*x+(db)y*y;
};
db ans=0;
vector<pii> vec[5];
for(int i=1;i<=4;i++)
for(int x=-MX*i;x<=MX*i;x++){
if(f[i][x+DT][0]==INF) continue;
for(auto y:f[i][x+DT]) vec[i].pb({x,y});
}
for(int i=1;i<=min(4,m);i++){
for(auto cur:vec[i]){
int x=cur.fi,y=cur.se;
ans=max(ans,dis2(x,y));
int c=(m-i)/4;
for(auto cur1:vec[4])
ans=max(ans,dis2(x+(i64)c*cur1.fi,y+(i64)c*cur1.se));
}
}
printf("Case #%d: %.10lf\n",tid,sqrt(ans));
}
int main(){
#ifdef LOCAL
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
#endif
int T=rdi();
for(int i=1;i<=T;i++) solve(i);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 4727ms
memory: 4244kb
input:
100 4 1 -2 4 1 -2 4 1 0 2 1 4 -5 0 2 5 -1 1 -2 2 10 8 -842 -60 148 -967 327 -600 -546 -346 -196 -267 -833 -156 334 -791 974 -382 -499 -785 519 -657 10 7 444 786 -313 649 -377 954 -872 316 505 714 678 170 40 -971 -290 -649 -824 -797 357 -653 10 9 -384 -28 267 -243 507 -628 -189 -656 373 -879 -115 -81...
output:
Case #1: 6.3245553203 Case #2: 10.0000000000 Case #3: 6.3245553203 Case #4: 10274.3879623070 Case #5: 10020.2324324339 Case #6: 11271.7292373442 Case #7: 4007.4156260613 Case #8: 9913.0499847423 Case #9: 10824.0991311056 Case #10: 8663.1749376311 Case #11: 9970.3284800452 Case #12: 11404.0947032195 ...
result:
wrong answer read 10274.387962307001 but expected 8072.663005477200 (test case 4)
Subtask #2:
score: 0
Time Limit Exceeded
Test #2:
score: 0
Time Limit Exceeded
input:
100 200 59153573 81 -81 -252 252 864 -864 -691 691 -599 599 -520 520 -835 835 334 -334 259 -259 -469 469 374 -374 -36 36 932 -932 -518 518 -882 882 -150 150 -392 392 29 -29 8 -8 -259 259 192 -192 -863 863 -88 88 -219 219 -118 118 485 -485 -953 953 -980 980 -14 14 433 -433 -672 672 352 -352 196 -196 ...