QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#479278 | #4739. Pionek | tjsyykkk | 0 | 0ms | 4296kb | C++11 | 1.1kb | 2024-07-15 16:13:41 | 2024-07-15 16:13:41 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans;
const double pi=3.14159;
struct vec{
int x,y;double a;
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();
return a.det(b)>0;
}
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],ans=max(ans,v[i].norm()),v[i].a=v[i].angle(),v[i+n].a=v[i].a+pi*2;//cout<<v[i].x<<" "<<v[i].y<<" "<<v[i].a<<endl;
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);
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4296kb
input:
5 2 -2 -2 -2 0 2 3 1 -3 1
output:
18
result:
wrong answer 1st numbers differ - expected: '26', found: '18'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%