QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#479217#4739. Pionektjsyykkk0 0ms4288kbC++111.0kb2024-07-15 15:59:282024-07-15 15:59:28

Judging History

This is the latest submission verdict.

  • [2024-07-15 15:59:28]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 4288kb
  • [2024-07-15 15:59:28]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans;
struct vec{
	int x,y;
	vec 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 id(){
		if(x>=0)return y>=0?1:4;
		return y>=0?2:3;
	}
	double angle(){
		return atan2(y,x);
	}
}v[600005];
bool cmp(vec a,vec b){
	//if(a.id()!=b.id())return a.id()<b.id();
	return a.angle()<b.angle();
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&v[n].x,&v[n].y);
	sort(v+1,v+n+1,cmp);
	for(int i=1;i<=n;i++)v[i+n]=v[i],ans=max(ans,v[i].norm());//cout<<v[i].x<<" "<<v[i].y<<endl;
	vec now=v[0];
	for(int l=1,r=0;l<=n;l++){
		now=now-v[l-1];
		if(r<l)r=l-1,now=v[0];
		while(r+1<l+n&&(now+v[r+1]).norm()>=now.norm())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: 0
Wrong Answer
time: 0ms
memory: 4288kb

input:

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

output:

10

result:

wrong answer 1st numbers differ - expected: '26', found: '10'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%