QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#744077#9576. Ordainer of Inexorable Judgmentdoyo#WA 0ms3844kbC++203.4kb2024-11-13 20:47:202024-11-13 20:47:22

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-13 20:47:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-11-13 20:47:20]
  • 提交

answer

#include<bits/stdc++.h>
#define double long double
using namespace std;
const double eps=1e-10;
const double pi=acos(-1.0);

#define rep(i,a,b) for(int i=a;i<(b);++i)
#define trav(a,x) for(auto & a : x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T>
struct Point
{
    typedef Point P;
    T x,y;
    explicit Point(T x=0,T y=0) :x(x),y(y) {}
    bool operator < (P p) const {return tie(x,y)<tie(p.x,p.y);}
    bool operator ==(P p) const {return abs(x-p.x)<eps&&abs(y-p.y)<eps;}

    P operator + (P p) const {return P(x+p.x,y+p.y);}
    P operator - (P p) const {return P(x-p.x,y-p.y);}
    P operator * (T d) const {return P(x*d,y*d);}
    P operator / (T d) const {return P(x/d,y/d);}
    T dot(P p) const {return x*p.x+y*p.y;}
    T cross(P p) const {return x*p.y-y*p.x;}
    T cross(P a,P b) const {return (a-*this).cross(b-*this);}
    T dist2() const {return x*x+y*y;}
    double dist() const {return sqrt((double)dist2());}
    double angle() const {return atan2(y,x);}
    P unit() const {return *this/dist();}
    P perp() const {return P(-y,x);}
    P normal() const {return perp().unit();}
    P rotate(double a) const {
        return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a));
    }
};

template<class P>
pair<P,P> circleTangents(const P &p,const P &c,double r)
{
    P a=p-c;
    double x=r*r/a.dist2(),y=sqrt(x-x*x);
    return make_pair(c+a*x+a.perp()*y,c+a*x-a.perp()*y);
}
typedef Point<double> P;
P base=P(1,0);
bool isReflex(P s,P t)
{
    auto c=s.cross(t);
    return c?(c<0):(s.dot(t)<0);
}
bool angleCmp(P s,P t)
{
    int r=isReflex(base,s)-isReflex(base,t);
    return r?(r<0):(0<s.cross(t));
}

void work()
{
    int n,x0,y0,d,t;
    std::cin>>n>>x0>>y0>>d>>t;
    P M=P(x0,y0);
    std::vector<P> vec(n);
    Point<double> O=P(0,0);
    std::vector<P> qie;
    for(int i=0;i<n;i++)    
    {
        int x,y;
        std::cin>>x>>y;
        vec[i]=P(x,y);
        auto [p1,p2]=circleTangents(O,vec[i],d);
        qie.push_back(p1);qie.push_back(p2);
    }

    vec.push_back(vec[0]);
    for(int i=1;i<vec.size();i++)
    {
        P p0;
        p0=vec[i]+(((vec[i]-vec[i-1]).rotate(1.5*pi)).unit())*d;
        qie.push_back(p0);
        p0=vec[i-1]+(((vec[i]-vec[i-1]).rotate(1.5*pi)).unit())*d;
        qie.push_back(p0);
    }
    std::sort(qie.begin(),qie.end(),angleCmp);
    double t0,t1,t2;
    auto ang=[](P p) ->double
    {
        
        if(p.y==0)
        {
            if(p.x>0) return 0;
            else return pi;
        }
        double res=p.angle();
        if(res<0) res=pi-res;
        return res;
    };
    //std::cout<<ang(P(-1,1))<<'\n';
    t0=ang(M);t1=ang(qie[0]),t2=ang(qie.back());
    t1-=t0;t2-=t0;
    //std::cout<<std::fixed<<std::setprecision(15)<<t1<<' '<<t2<<'\n';
    double ans=0;
    while(t1<0) t1+=2*pi;
    while(t2<0) t2+=2*pi;
    if(t1>t2) 
    {
        ans+=std::min(t2,(double)t);
        t2+=2*pi;
    }
    while(t1+eps<t&&t2+eps<t)
    {
        ans+=std::max(t2-t1,(double)0.0);
        t1+=2*pi;t2+=2*pi;
    }
    if(t1+eps<t) ans+=t-t1;
    std::cout<<std::fixed<<std::setprecision(15)<<ans<<'\n';
}

int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //std::cin>>t;
    while(t--)
        work();
    return 0;
}

详细

Test #1:

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

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1.000000000000000

result:

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

Test #2:

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

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.570796326794897

result:

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

Test #3:

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

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.707752257475330

result:

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

Test #4:

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

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

0.384241300290627

result:

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

Test #5:

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

input:

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

output:

2499.136955930680391

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '2499.1369559', error = '0.0004414'