QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#479199 | #4739. Pionek | tjsyykkk | 0 | 0ms | 3864kb | C++11 | 1.0kb | 2024-07-15 15:53:50 | 2024-07-15 15:53:50 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans,m;
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;
}
}v[600005];
bool cmp(vec a,vec b){
//if(a.id()!=b.id())return a.id()<b.id();
return a.det(b)>0;
}
signed main(){
scanf("%lld",&m);n=1;
for(int i=1;i<=m;i++)scanf("%lld%lld",&v[n].x,&v[n].y),n+=!(v[n].x==0&&v[n].y==0);
n--;
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: 15
Accepted
time: 0ms
memory: 3756kb
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: 3864kb
input:
1 -2 3
output:
13
result:
ok 1 number(s): "13"
Test #3:
score: -15
Wrong Answer
time: 0ms
memory: 3812kb
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:
4357
result:
wrong answer 1st numbers differ - expected: '4930', found: '4357'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%