QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#586978 | #784. 旋转卡壳 | houbur | 0 | 1ms | 5972kb | C++20 | 1.5kb | 2024-09-24 16:53:40 | 2024-09-24 16:53:41 |
Judging History
你现在查看的是最新测评结果
- [2024-10-16 12:18:36]
- hack成功,自动添加数据
- (/hack/1005)
- [2024-09-24 16:55:39]
- hack成功,自动添加数据
- (/hack/888)
- [2024-09-24 16:53:40]
- 提交
answer
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define double long double
const int N=5e5+5;
int n,m,top,xx,yy;
struct sb{
double x,y,k;
}e[N],st[N];
inline bool cmp(sb a,sb b){return (a.y==b.y)?(a.x<b.x):(a.y<b.y);}
inline double cross(sb a,sb b,sb c){return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);}
inline double ddd(sb a,sb b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
inline double dis(sb a,sb b,sb c){
double k=(b.y-c.y)/(b.x-c.x);
double bb=b.y-k*b.x;
return fabs(k*a.x-a.y+bb)/sqrt(k*k+1);
}
inline bool cmpp(sb a,sb b){
if(a.k!=b.k)return a.k<b.k;
if(a.x==b.x)return a.y<b.y;
return a.x<b.x;
}
signed main(){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>e[i].x>>e[i].y;
sort(e+1,e+1+n,cmp);
st[++top]=e[1];
xx=st[top].x,yy=st[top].y;
for(int i=2;i<=n;i++)e[i].k=atan2(e[i].y-yy,e[i].x-xx);
sort(e+2,e+1+n,cmpp);
st[++top]=e[2];
for(int i=3;i<=n;i++){
while(top>1&&cross(st[top-1],st[top],e[i])<0)top--;
st[++top]=e[i];
}
int l=1,r=1;
double ans=0;
for(l=1;l<top;l++){
int op=r;
while(dis(st[r%top+1],st[l+1],st[l])>=dis(st[r],st[l+1],st[l])){
r=r%top+1;
if(r==op){
ans=max({ans,ddd(st[r],st[l]),ddd(st[r],st[l+1]),ddd(st[l],st[l+1])});
break;
}
}
ans=max({ans,ddd(st[r],st[l]),ddd(st[r],st[l+1]),ddd(st[l],st[l+1])});
}
printf("%.7Lf",ans*ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5972kb
input:
1000 0 0 -997615 -8573 -1988394 -28911 -2726572 -44296 -3491635 -60392 -4419752 -82814 -5298550 -105946 -5723430 -118453 -6608257 -147267 -7034966 -161982 -7563964 -181682 -8507871 -222865 -9499799 -271846 -10090186 -303547 -10400262 -322989 -10614073 -339725 -11081438 -378596 -11791568 -439127 -127...
output:
5664370055953136725586519728848896.0000000
result:
wrong answer 1st numbers differ - expected: '274339223.1895614', found: '5664370055953136360231999958417408.0000000', error = '20647321189063811313696768.0000000'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%