QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#115232#5904. Twirling Towards Freedomzhouhuanyi49 ✓616ms21272kbC++112.4kb2023-06-25 11:27:062023-06-25 11:27:08

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-25 11:27:08]
  • 评测
  • 测评结果:49
  • 用时:616ms
  • 内存:21272kb
  • [2023-06-25 11:27:06]
  • 提交

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 (__int128)(b.y-a.y)*(c.x-a.x)<=(__int128)(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--;
	dque[++top]=p[i];
    }
    for (int i=1;i<=top;++i) st.push_back(dque[i]);
    top=0;
    for (int i=0;i<p.size();++i)
    {
	while (top>=2&&check(dque[top-1],p[i],dque[top])) top--;
	dque[++top]=p[i];
    }
    for (int i=2;i<=top-1;++i) st.push_back(dque[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);
	    if (sm%4==0) res=solve(solve(solve(A+B)+C)+D);
	    else if (sm%4==1) res=solve(A+solve(solve(B+C)+D));
	    else if (sm%4==2) res=solve(solve(A+B)+solve(C+D));
	    else res=solve(solve(solve(A+B)+C)+D);
	    for (int i=0;i<res.size();++i) ans=max(ans,sqrt(1.0*res[i].x*res[i].x+1.0*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: 10
Accepted

Test #1:

score: 10
Accepted
time: 6ms
memory: 3732kb

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: 39
Accepted

Test #2:

score: 39
Accepted
time: 616ms
memory: 21272kb

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
...

output:

Case #1: 82359120550.7561340332
Case #2: 84510626188.2999267578
Case #3: 70661053401.3009338379
Case #4: 109064878459.4080963135
Case #5: 31887461051.9420623779
Case #6: 44597031797.9429397583
Case #7: 16108038453.3387355804
Case #8: 88820696855.7596588135
Case #9: 38768573735.9652099609
Case #10: 2...

result:

ok correct! (100 test cases)

Extra Test:

score: 0
Extra Test Passed