QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#115712 | #5904. Twirling Towards Freedom | Zesty_Fox | 10 | 7815ms | 4196kb | C++20 | 2.3kb | 2023-06-26 16:51:05 | 2023-06-26 16:51:08 |
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;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 7815ms
memory: 4196kb
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: 8072.6630054772 Case #5: 9582.0846374889 Case #6: 9520.9500576361 Case #7: 3136.8787034248 Case #8: 9405.6161945935 Case #9: 9809.6108995209 Case #10: 8356.3092331483 Case #11: 8863.7475144546 Case #12: 10066.9729313235 Case...
result:
ok correct! (100 test cases)
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 ...