QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#479751#4739. Pionektjsyykkk0 0ms4228kbC++111.1kb2024-07-15 20:43:242024-07-15 20:43:24

Judging History

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

  • [2024-07-15 20:43:24]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:4228kb
  • [2024-07-15 20:43:24]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const double pi=1.570796;
int n,ans;
struct vec{
	int x,y;double a;
	vec friend operator+(vec a,vec b){
		return {a.x+b.x,a.y+b.y};
	}
	bool friend operator==(vec a,vec b){
		return a.x==b.x&&a.y==b.y;
	}
	vec friend operator-(vec a,vec b){
		return {a.x-b.x,a.y-b.y};
	}
	int norm(){
		return x*x+y*y;
	}
	int det(vec b){
		return x*b.y-y*b.x;
	}
	int dot(vec b){
		return x*b.x+y*b.y;
	}
	int get(){
		return y>0||(y==0&&x>=0);
	}
	double angle(){
		return atan2(y,x);
	}
}v[600005];
bool cmp(vec a,vec b){
	if(a.get()==b.get())return a.det(b)>0||(a.det(b)==0&&a.norm()<b.norm());
	return a.get()>b.get();
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&v[i].x,&v[i].y);
	sort(v+1,v+n+1,cmp);
	for(int i=1;i<=n;i++)v[i+n]=v[i],v[i].a=v[i].angle()+pi*2*(v[i].a<0),v[i+n].a=v[i].a+pi*2;
	vec now=v[0];
	for(int l=1,r=0;l<=n;l++){
		now=now-v[l-1];ans=max(ans,now.norm());
		while(r+1<l+n&&v[r+1].a-v[l].a<pi)now=now+v[++r],ans=max(ans,now.norm());
		//cout<<l<<" "<<r<<" "<<now.norm()<<endl;
	}
	printf("%lld",ans);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 15
Accepted
time: 0ms
memory: 4164kb

input:

5
2 -2
-2 -2
0 2
3 1
-3 1

output:

26

result:

ok 1 number(s): "26"

Test #2:

score: 0
Accepted
time: 0ms
memory: 4228kb

input:

1
-2 3

output:

13

result:

ok 1 number(s): "13"

Test #3:

score: -15
Wrong Answer
time: 0ms
memory: 4228kb

input:

20
-3 -8
-5 -5
-4 2
4 -4
-5 -4
-8 9
-4 1
-2 -3
2 0
-2 -10
-7 7
4 3
-7 2
-5 -3
-9 -9
1 6
7 -9
-8 8
7 -9
10 -2

output:

4673

result:

wrong answer 1st numbers differ - expected: '4930', found: '4673'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%