QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#827470#9576. Ordainer of Inexorable JudgmentLcyanstarsWA 0ms4332kbC++201.5kb2024-12-22 23:38:052024-12-22 23:38:06

Judging History

This is the latest submission verdict.

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-22 23:38:06]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4332kb
  • [2024-12-22 23:38:05]
  • Submitted

answer

#include <bits/stdc++.h>

struct Point
{
    int x,y;
    Point(int _x=0,int _y=0):x(_x),y(_y){}
    Point operator -(Point a)
    {
        return {x-a.x,y-a.y};
    }
};

int cross(Point a,Point b)
{
    return a.x*b.y-a.y*b.x;
}

int cross(Point a,Point b,Point c)
{
    return cross(b-a,c-a);
}

int main()
{
    int n;
    Point p_0;
    double d,t;
    scanf("%d%d%d%lf%lf",&n,&p_0.x,&p_0.y,&d,&t);
    std::vector<Point> p(n);
    for(int i=0;i<n;i++)
        scanf("%d%d",&p[i].x,&p[i].y);
    bool ok=true;
    for(int i=0;i<n;i++)
        if(cross(p[i],p[(i+1)%n])<0)
            ok=false;
    if(ok)
    {
        printf("%.12lf\n",t);
        return 0;
    }
    const double pi=acos(-1),eps=1e-7;
    double mx=0,mn=2*pi;
    for(int i=0;i<n;i++)
    {
        double L=sqrt(p[i].x*p[i].x+p[i].y*p[i].y);
        double del=asin(d/L);
        double ang=atan2(p[i].y,p[i].x);
        double res[]{ang+del,ang-del};
        for(int j=0;j<2;j++)
        {
            while(res[j]<-eps)
                res[j] += 2*pi;
            while(res[j] >= 2*pi-eps)
                res[j] -= 2*pi;
            mx=std::max(res[j],mx);
            mn=std::min(res[j],mn);
        }
    }
    if(mx-mn >= pi-eps)
    {
        std::swap(mx,mn);
        mn -= 2*pi;
    }
    int T=floor(t/(2*pi));
    t -= T*(2*pi);
    double ans=T*(mx-mn)+std::min({std::max(mx-atan2(p_0.y,p_0.x),0.0),mx-mn,t});
    printf("%.12lf\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1.000000000000

result:

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

Test #2:

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

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.570796326795

result:

ok found '1.5707963', expected '1.5707963', error '0.0000000'

Test #3:

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

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.707752257475

result:

ok found '2500.7077523', expected '2500.7077523', error '0.0000000'

Test #4:

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

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

0.384241300290

result:

ok found '0.3842413', expected '0.3842413', error '0.0000000'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 4180kb

input:

3 -10000 -10000 10000 10000
-10000 -9999
-10000 -10000
-9999 -10000

output:

2501.026168178006

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '2501.0261682', error = '0.0003142'