QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#743902#9576. Ordainer of Inexorable Judgmentdoyo#Compile Error//C++203.3kb2024-11-13 20:16:052024-11-13 20:16:10

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:16:10]
  • 评测
  • [2024-11-13 20:16:05]
  • 提交

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+=t2,t2+=2*pi;
    while(t1+eps<t&&t2+eps<t)
    {
        ans+=std::max(t2-t1,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;
}

詳細信息

answer.code: In function ‘void work()’:
answer.code:112:22: error: no matching function for call to ‘max(long double, double)’
  112 |         ans+=std::max(t2-t1,0.0);
      |              ~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:112:22: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long double’ and ‘double’)
  112 |         ans+=std::max(t2-t1,0.0);
      |              ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:112:22: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long double’ and ‘double’)
  112 |         ans+=std::max(t2-t1,0.0);
      |              ~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:112:22: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long double’
  112 |         ans+=std::max(t2-t1,0.0);
      |              ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:112:22: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long double’
  112 |         ans+=std::max(t2-t1,0.0);
      |              ~~~~~~~~^~~~~~~~~~~