QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555930#9253. Prism PalaceJZYZWA 36ms12104kbC++141002b2024-09-10 12:43:092024-09-10 12:43:09

Judging History

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

  • [2024-09-10 12:43:09]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:12104kb
  • [2024-09-10 12:43:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
template <typename T>inline void read(T &x)
{
    x=0;char c=getchar();bool f=0;
    for(;c<'0'||c>'9';c=getchar())f|=(c=='-');
    for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c-'0');
    x=(f?-x:x);
}
const int N = 2e5+7;
int n;
typedef double db;
const db pi =acos(-1);
struct node
{
    double x,y;
}p[N],q[N];
node operator -(node a,node b)
{
    return (node){a.x-b.x,a.y-b.y};
}
double arc[N];
double ang(node v)
{
    return atan2(v.y,v.x);
}
double mod(double t)
{
    while(t<0)t+=pi;
    while(t>pi)t-=pi;
    return t;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%lf %lf",&q[i].x,&q[i].y);
    }
    for(int i=0;i<n;i++)p[i]=q[(i+1)%n]-q[i];
    for(int i=0;i<n;i++)
    arc[i]=mod(-ang(p[(i+1)%n])+ang(p[i]));
    db res=0;
    for(int i=0;i<n;i++)
    {
        res+=max(0.0,pi-arc[i]-arc[(i+1)%n]);
    }
    res/=pi;
    printf("%.10lf",res);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 6188kb

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: 8292kb

input:

4
0 0
0 3
1 2
1 1

output:

0.5000000000

result:

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

Test #4:

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

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

result:

wrong answer 1st numbers differ - expected: '0.0000777', found: '199992.0000777', error = '199992.0000000'