QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722766#9576. Ordainer of Inexorable JudgmentMu_SilkWA 1ms4244kbC++232.1kb2024-11-07 20:08:362024-11-07 20:08:37

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-11-14 21:58:28]
  • hack成功,自动添加数据
  • (/hack/1181)
  • [2024-11-07 20:08:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4244kb
  • [2024-11-07 20:08:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define double long double

const double eps=1e-8;
int sgn(double x){
    if(x>eps)return 1;
    if(x<-eps)return -1;
    return 0;
} 

struct vec{
    double x,y;
    vec operator-(vec a){return {x-a.x,y-a.y};}
    vec operator-(){return {-x,-y};}
    double len(){return hypotl(x,y);}
    vec rot90(){return {-y,x};}
    vec rotate(double c){
        return {x*cosl(c)-y*sinl(c),x*sinl(c)+y*cosl(c)};
    }
};

double cross(vec a,vec b){
    return a.x*b.y-a.y*b.x;
}

struct cir{
    vec o{0,0};
    double r;
};

int getTangents(vec p,cir c,vec& v0,vec& v1){
    vec u=c.o-p;
    double dist=u.len();
    if(sgn(dist-c.r)<0)return 0;
    if(!sgn(dist-c.r)){
        v0=u.rot90();
        return 1;
    }
    double ang=asinl(c.r/dist);
    v0=u.rotate(-ang);
    v1=u.rotate(ang);
    return 2;
}

const double pi=acosl(-1);

void solve(){
    int n;
    vec d;
    cir c;c.o={0,0};
    double t;
    cin>>n>>d.x>>d.y>>c.r>>t;

    vector<vec> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].x>>v[i].y;
    }
    vec l0,r0;
    for(int i=0;i<n;i++){
        vec l,r;
        getTangents(v[i],c,l,r);
        l=-l;r=-r;
        if(i==0)l0=l,r0=r;
        else{
            if(sgn(cross(l,l0))>=0)l0=l;
            if(sgn(cross(r0,r))>=0)r0=r;
        }
        // cout<<atan2(l.y,l.x)<<" "<<atan2(r.y,r.x)<<"\n";
    }
    double a=atan2l(d.y,d.x);

    double al=atan2l(l0.y,l0.x);
    double ar=atan2l(r0.y,r0.x);
    al-=a;ar-=a;
    if(sgn(al)<0)al+=2*pi;
    if(sgn(ar)<0)ar+=2*pi;
    a=ar-al;if(sgn(a)<0)a+=2*pi;

    double cnt=floorl(t/(2*pi));
    double ans=cnt*a;
    t-=cnt*(2*pi);
    if(ar>=al){
        if(t>al);
        ans+=min(t-al,ar-al);
    }
    else{
        ans+=min(t,ar);
        if(t>al)ans+=t-al;
    }

    
    // cout<<atan2(l0.y,l0.x)<<" "<<atan2(r0.y,r0.x)<<"\n";
    cout<<fixed<<setprecision(12)<<ans<<"\n";

}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n=1;
    //cin>>n;
    while(n--)solve();
    return 0;
}

詳細信息

Test #1:

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

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

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

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

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: 0
Accepted
time: 0ms
memory: 4188kb

input:

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

output:

2500.240670009608

result:

ok found '2500.2406700', expected '2500.2406700', error '0.0000000'

Test #6:

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

input:

4 1 0 1 10000
-2 3400
-4 10000
-4 -10000
-2 -3400

output:

4999.219115408743

result:

ok found '4999.2191154', expected '4999.2191154', error '0.0000000'

Test #7:

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

input:

4 1 0 1 10000
-2 3300
-4 10000
-4 -10000
-2 -3300

output:

4999.200391854815

result:

ok found '4999.2003919', expected '4999.2003919', error '0.0000000'

Test #8:

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

input:

4 -3040 2716 2147 2
-9033 -8520
-8999 -8533
-8988 -8511
-9004 -8495

output:

0.350830058342

result:

ok found '0.3508301', expected '0.3508301', error '0.0000000'

Test #9:

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

input:

3 8168 -766 1549 1256
-3951 -6425
-3874 -6439
-3911 -6389

output:

84.832861161007

result:

ok found '84.8328612', expected '84.8328612', error '0.0000000'

Test #10:

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

input:

8 2977 -3175 8766 2
-4868 7759
-4867 7925
-4867 7950
-4886 7952
-4979 7953
-5048 7877
-5003 7761
-4936 7759

output:

0.327860646906

result:

ok found '0.3278606', expected '0.3278606', error '0.0000000'

Test #11:

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

input:

13 -1715 -4640 267 8651
272 6659
264 6660
208 6664
108 6625
107 6621
93 6564
90 6551
90 6485
124 6474
219 6477
283 6525
288 6591
286 6657

output:

153.589622784682

result:

ok found '153.5896228', expected '153.5896228', error '0.0000000'

Test #12:

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

input:

8 -9743 -7629 775 7
-194 981
-191 1720
-193 1845
-705 1929
-959 1950
-1131 1894
-1151 1604
-1031 1020

output:

-0.593785938561

result:

wrong answer 1st numbers differ - expected: '2.0460062', found: '-0.5937859', error = '1.2902171'