QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751617#9576. Ordainer of Inexorable JudgmentQingTianWA 1ms4272kbC++203.0kb2024-11-15 19:48:132024-11-15 19:48:14

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-11-15 19:48:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4272kb
  • [2024-11-15 19:48:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const ld eps=1e-8,pi=acosl(-1);
int sgn(ld x){
    if(fabs(x)<eps) return 0;
    if(x>0) return 1;
    return -1;
}
struct p2{
    ld x,y;
    friend p2 operator+(p2 a,p2 b){return {a.x+b.x,a.y+b.y};}
    friend p2 operator-(p2 a,p2 b){return {a.x-b.x,a.y-b.y};}
    friend p2 operator*(ld a,p2 b){return {a*b.x,a*b.y};}
    friend ld operator*(p2 a,p2 b){return a.x*b.x+a.y*b.y;}
    friend ld operator^(p2 a,p2 b){return a.x*b.y-a.y*b.x;}
    friend bool operator<(p2 a,p2 b){
        return (a^b)>0;
    }
    void rd(){
        int xx,yy;cin>>xx>>yy;
        x=xx,y=yy;
    }
    void db(){cerr<<fixed<<setprecision(12)<<x<<' '<<y<<'\n';}
    p2 rot(p2 o,ld a){
        ld x1=(x-o.x)*cosl(a)-(y-o.y)*sinl(a)+o.x;
        ld y1=(y-o.y)*cosl(a)+(x-o.x)*sinl(a)+o.y;
        return {x1,y1};
    }
    ld len(){return sqrt(x*x+y*y);}
};
ld PtoL(p2 a,p2 b,p2 c){//c->ab
    p2 v1=b-a,v2=c-a;
    return fabs((v1^v2)/v1.len());
}
ld PtoS(p2 a,p2 b,p2 c){
    if((a-c)*(a-b)<0) return (a-c).len();
    if((b-c)*(b-a)<0) return (b-c).len();
    return PtoL(a,b,c);
}
pair<p2,p2> getC(p2 a,p2 O,ld r){
    ld sita=asinl(r/(a-O).len());
    cerr<<"sita "<<sita<<'\n';
    p2 s1=O.rot(a,sita);
    p2 s2=O.rot(a,-sita);
    return {s1-a,s2-a};
}
ld getrad(p2 a,p2 b){
    return acosl(a*b/a.len()/b.len());
}
ld getAng(p2 a){
    ld x=atan2(a.y,a.x);
    return x;
}
void solve(){
    int n;
    ld d,t;
    p2 p0;
    p2 O={0,0};
    cin>>n>>p0.x>>p0.y>>d>>t;
    vector<p2> v(n);
    for(int i=0;i<n;i++) v[i].rd();
	cout<<fixed<<setprecision(12);
    //判断原点在信用卡凸包内
    for(int i=0;i<n;i++){
        if(PtoS(v[i],v[(i+1)%n],O)<=d){
            cout<<t<<'\n';
            return;
        }
    }

    p2 mn,mx;
    auto tp=getC(O,v[0],d);
    mn=tp.first,mx=tp.second;
    if(mx<mn) swap(mx,mn);
    for(int i=1;i<n;i++){
        tp=getC(O,v[i],d);
        if(tp.first<mn) mn=tp.first;
        if(mx<tp.first) mx=tp.first;
        if(tp.second<mn) mn=tp.second;
        if(mx<tp.second) mx=tp.second;
    }
    ld rds=floor(t/(2*pi));
    ld remain=t-rds*(2*pi);

	
    ld res=rds*getrad(mn,mx);
	cerr<<rds<<' '<<getrad(mn,mx)<<'\n';
    ld b=getAng(p0);
    ld st=getAng(mn);
    ld ed=getAng(mx);
    

    st-=b,ed-=b;

    
    if(st>=0 && ed>=0){
        if(remain>ed) res+=ed-st;
        else if(remain>st) res+=remain-st;
    }else if(st>=0 && ed<=0){
        ed+=2*pi;
        if(remain>ed) res+=ed-st;
        else if(remain>st) res+=remain-st;
    }else if(st<=0 && ed>=0){
        st+=2*pi;
        if(remain>st){
            res+=remain-st+ed;
        }else if(remain>ed){
            res+=ed;
        }else res+=remain;
    }else if(st<=0 && ed<=0){
        st+=2*pi,ed+=2*pi;
        if(remain>ed) res+=ed-st;
        else if(remain>st) res+=remain-st;
    }
    cout<<res<<'\n';

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

詳細信息

Test #1:

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

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

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

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

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

0.384241300291

result:

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

Test #5:

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

input:

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

output:

2494.742982870826

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '2494.7429829', error = '0.0021989'