QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#115229 | #5904. Twirling Towards Freedom | zhouhuanyi | 0 | 0ms | 0kb | C++11 | 2.2kb | 2023-06-25 10:58:30 | 2023-06-25 10:58:31 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#define N 5000
using namespace std;
int read()
{
char c=0;
int sum=0,f=1;
while (c!='-'&&(c<'0'||c>'9')) c=getchar();
if (c=='-') c=getchar(),f=-1;
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum*f;
}
struct points
{
long long x,y;
bool operator < (const points &t)const
{
return (x!=t.x)?x<t.x:y<t.y;
}
};
points st[N+1],dque[N+1];
vector<points>A;
vector<points>B;
vector<points>C;
vector<points>D;
vector<points>res;
int T,n,m,sm,top;
bool check(points a,points b,points c)
{
return (b.y-a.y)*(c.x-a.x)<=(c.y-a.y)*(b.x-a.x);
}
vector<points>operator + (vector<points>a,vector<points>b)
{
vector<points>c;
for (int i=0;i<a.size();++i)
for (int j=0;j<b.size();++j)
c.push_back((points){a[i].x+b[j].x,a[i].y+b[j].y});
return c;
}
vector<points>solve(vector<points>p)
{
vector<points>st;
sort(p.begin(),p.end()),top=0;
for (int i=0;i<p.size();++i)
{
while (top>=2&&check(dque[top-1],dque[top],p[i])) top--;
st.push_back(p[i]),dque[++top]=p[i];
}
top=0;
for (int i=(int)(p.size())-1;i>=0;--i)
{
while (top>=2&&check(dque[top-1],p[i],dque[top])) top--;
if (i&&i+1!=p.size()) st.push_back(p[i]);
dque[++top]=p[i];
}
return st;
}
int main()
{
int x,y;
double ans;
T=read();
for (int qt=1;qt<=T;++qt)
{
n=read(),m=read(),ans=0;
for (int i=1;i<=n;++i) x=read(),y=read(),st[i].x=x-y,st[i].y=x+y;
for (int w=0;w<=min(3,m);++w)
{
sm=m-w,A.clear(),B.clear(),C.clear(),D.clear();
for (int i=1;i<=n;++i)
{
A.push_back((points){st[i].x*((sm+3)>>2),st[i].y*((sm+3)>>2)});
B.push_back((points){st[i].y*((sm+2)>>2),-st[i].x*((sm+2)>>2)});
C.push_back((points){-st[i].x*((sm+1)>>2),-st[i].y*((sm+1)>>2)});
D.push_back((points){-st[i].y*(sm>>2),st[i].x*(sm>>2)});
}
A=solve(A),B=solve(B),C=solve(C),D=solve(D),res=A,res=solve(res+B),res=solve(res+C),res=solve(res+D);
for (int i=0;i<res.size();++i) ans=max(ans,sqrt(res[i].x*res[i].x+res[i].y*res[i].y));
}
printf("Case #%d: %0.10lf\n",qt,ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
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:
result:
Subtask #2:
score: 0
Memory Limit Exceeded
Test #2:
score: 0
Memory 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 ...