QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#585616#784. 旋转卡壳houbur0 1ms5924kbC++201.3kb2024-09-23 21:30:352024-09-23 21:30:35

Judging History

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

  • [2024-10-16 12:18:36]
  • hack成功,自动添加数据
  • (/hack/1005)
  • [2024-09-24 16:55:39]
  • hack成功,自动添加数据
  • (/hack/888)
  • [2024-09-23 21:30:35]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5924kb
  • [2024-09-23 21:30:35]
  • 提交

answer

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=2e6+5;
int n,m,top,xx,yy;
struct sb{
	double x,y;
}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 dis(sb a,sb b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(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 bool cmpp(sb a,sb b){
	// double k1=atan2(a.y-yy,a.x-xx),k2=atan2(b.y-yy,b.x-xx);
	// if(k1!=k2)return k1<k2;
	if(a.x==b.x)return a.y<b.y;
	return a.x<b.x;
}
signed main(){
	// freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
	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;
	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];
	}
	for(int i=1;i<=top;i++)st[i+top]=st[i];
	int mx=0,l=1,r=1;
	for(int i=1;i<=top;i++){
		int op=dis(st[i],st[1]);
		if(op>mx){mx=op;r=i;}
		else break;
	}
	double ans=0;
	for(l=1;l<=top;l++){
		while(r<=top*2&&dis(st[r+1],st[l])>=dis(st[r],st[l]))r++;
		ans=max(ans,sqrt((st[l].x-st[r].x)*(st[l].x-st[r].x)+(st[l].y-st[r].y)*(st[l].y-st[r].y)));
	}
	printf("%.7lf",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: 5924kb

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:

259523030.1391223

result:

wrong answer 1st numbers differ - expected: '274339223.1895614', found: '259523030.1391223', error = '0.0540068'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%