QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551059#9253. Prism Palaceucup-team052#WA 28ms7344kbC++231.1kb2024-09-07 15:14:482024-09-07 15:14:49

Judging History

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

  • [2024-09-07 15:14:49]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:7344kb
  • [2024-09-07 15:14:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 200005
struct Vec
{
	int x,y;
	Vec(int a=0,int b=0) {x=a,y=b;}
	double norm() {return sqrt(x*x+y*y);}
};
Vec operator + (Vec x,Vec y) {return Vec(x.x+y.x,x.y+y.y);}
Vec operator - (Vec x,Vec y) {return Vec(x.x-y.x,x.y-y.y);}
int cross(Vec x,Vec y) {return 1LL*x.x*y.y-1LL*x.y*y.x;}
int cdot(Vec x,Vec y) {return 1LL*x.x*y.x+1LL*x.y*y.y;}
int sgn(int x)
{
	if(x<0) return -1;
	else if(x==0) return 0;
	else return 1;
}
int ccw(Vec x,Vec y,Vec z) {return cross(y-x,z-x);}
int n;
Vec a[N];
const double pi=acos(-1);
signed main() {
#ifdef xay5421
	freopen("b.in","r",stdin);
#else
	ios::sync_with_stdio(0),cin.tie(0);
#endif
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i].x>>a[i].y;
	if(ccw(a[0],a[1],a[2])==-1) reverse(a,a+n);
	double ans=0;
	for(int i=0;i<n;i++)
	{
		if(sgn(cross(a[(i-1+n)%n]-a[i],a[(i+2)%n]-a[(i+1)%n]))==1)
		{
			double w=cross(a[(i-1+n)%n]-a[i],a[(i+2)%n]-a[(i+1)%n]);
			w/=(a[(i-1+n)%n]-a[i]).norm();
			w/=(a[(i+2)%n]-a[(i+1)%n]).norm();
			ans+=asin(w);
		}
	}
	printf("%.10lf\n",ans/pi);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7248kb

input:

3
0 0
1 0
0 1

output:

1.0000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7060kb

input:

4
0 0
0 1
1 1
1 0

output:

0.0000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 7344kb

input:

4
0 0
0 3
1 2
1 1

output:

0.4999999953

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #4:

score: -100
Wrong Answer
time: 28ms
memory: 7316kb

input:

199996
719157942 80035870
719158808 80033199
719160795 80027070
719162868 80020675
719165635 80012139
719166422 80009711
719166927 80008153
719168388 80003645
719168539 80003179
719168806 80002355
719168864 80002176
719169119 80001389
719171067 79995376
719173806 79986921
719175195 79982633
71917686...

output:

2.9977660534

result:

wrong answer 1st numbers differ - expected: '0.0000777', found: '2.9977661', error = '2.9976883'