QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#834801#9253. Prism PalacedoctorZ_WA 33ms6572kbC++141.1kb2024-12-28 00:25:472024-12-28 00:25:48

Judging History

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

  • [2024-12-28 00:25:48]
  • 评测
  • 测评结果:WA
  • 用时:33ms
  • 内存:6572kb
  • [2024-12-28 00:25:47]
  • 提交

answer

#include<cstdio>
#include<cmath> 
#define db double
using namespace std;
const db pi=acos(-1.0);
const int N=1e6+100;
int n;
struct comp
{
	db x,y;
}p[N+10];
comp operator -(comp x,comp y)
{
	return (comp){x.x-y.x,x.y-y.y}; 
}
db lent(comp x){return sqrt(x.x*x.x+x.y*x.y);}
db getangle(comp x,comp y)
{
	db res=atan2(x.x,x.y)-atan2(y.x,y.y);
	while(res>pi/2) res-=pi;
	while(res<-pi/2) res+=pi;
	return abs(res);
}
db getangle1(comp x,comp y)
{
	return acos(abs(x.x*y.x+x.y*y.y)/lent(x)/lent(y));
}
db across(comp x,comp y)
{
	return x.x*y.y-x.y*y.x; 
}
int id(int x)
{
	if(x<=0) x+=n;
	if(x>n) x-=n;
	return x;
}
int main()
{
//	freopen("ll.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lf %lf",&p[i].x,&p[i].y);
//	printf("%lf\n",getangle(p[2],p[3]));
	db ans=0;
	for(int i=1;i<=n;i++)
	{
		comp x=p[i]-p[id(i-1)],y=p[id(i+1)]-p[id(i+2)];
		if(across(x,y)>0){
//			printf("%lf %lf\n",getangle(x,y),getangle1(x,y));
//			printf("%lf %lf %lf %lf\n",x.x,x.y,y.x,y.y);
			ans+=getangle(x,y);
		}
	}
	printf("%.9lf\n",ans/pi);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 2408kb

input:

3
0 0
1 0
0 1

output:

1.000000000

result:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 1948kb

input:

4
0 0
0 1
1 1
1 0

output:

0.000000000

result:

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

Test #3:

score: 0
Accepted
time: 0ms
memory: 2380kb

input:

4
0 0
0 3
1 2
1 1

output:

0.500000000

result:

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

Test #4:

score: -100
Wrong Answer
time: 33ms
memory: 6572kb

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.997766053

result:

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