QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834804 | #9253. Prism Palace | doctorZ_ | WA | 38ms | 6216kb | C++14 | 1.1kb | 2024-12-28 00:35:52 | 2024-12-28 00:35:53 |
Judging History
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 ang=atan2(x.x,x.y)-atan2(y.x,y.y);
while(ang < 0) ang += 2. * pi;
while(ang > 2. * pi) ang -= 2. * pi;
return ang;
}
db getangle1(comp x,comp y)
{
return acos(abs(x.x*y.x+x.y*y.y)/lent(x)/lent(y));
}
long long across(comp x,comp y)
{
return (long long)x.x*(long long)y.y-(long long)x.y*(long long)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: 2356kb
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: 2084kb
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: 2308kb
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: 38ms
memory: 6216kb
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:
199992.000077718
result:
wrong answer 1st numbers differ - expected: '0.0000777', found: '199992.0000777', error = '199992.0000000'