QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#834797#9253. Prism PalacedoctorZ_WA 36ms6788kbC++14954b2024-12-28 00:06:482024-12-28 00:06:48

Judging History

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

  • [2024-12-28 00:06:48]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:6788kb
  • [2024-12-28 00:06:48]
  • 提交

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)
{
	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("%d %d %lf\n",i,i+1,getangle(x,y));
//			printf("%lf %lf %lf %lf\n",x.x,x.y,y.x,y.y);
			ans+=getangle(x,y);
		}
	}
	printf("%lf\n",ans/pi);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0 0
1 0
0 1

output:

1.000000

result:

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

Test #2:

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

input:

4
0 0
0 1
1 1
1 0

output:

0.000000

result:

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

Test #3:

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

input:

4
0 0
0 3
1 2
1 1

output:

0.500000

result:

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

Test #4:

score: -100
Wrong Answer
time: 36ms
memory: 6788kb

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

result:

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