QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#599904#9434. Italian CuisinetarjenCompile Error//C++203.7kb2024-09-29 13:02:532024-09-29 13:02:57

Judging History

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

  • [2024-09-29 13:02:57]
  • 评测
  • [2024-09-29 13:02:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll=__int128;
using point_t=ll;  //全局数据类型,可修改为 long long 等
// ll abs(ll x){
//     if(x<0)return -x;
//     return x;
// }
istream& operator >> (istream& in, __int128& num) {
    string s;in>>s;
    num=0;
    ll fx=1;
    for(auto it:s){
        if(it=='-')fx=-1;
        else num=num*10+it-'0';
    }
    num=num*fx;
    return in;
}

ostream& operator << (ostream& out, __int128 num) {
    string s;
    do{
        s.push_back(char(num%10+'0'));
        num/=10;
    }while(num>0);
    reverse(s.begin(),s.end());
    out<<s;
    return out;
}

constexpr point_t eps=0;
constexpr long double PI=3.1415926535897932384l;

// 点与向量
template<typename T> struct point
{
    T x,y;

    bool operator==(const point &a) const {return (abs(x-a.x)<=eps && abs(y-a.y)<=eps);}
    bool operator<(const point &a) const {if (abs(x-a.x)<=eps) return y<a.y-eps; return x<a.x-eps;}
    bool operator>(const point &a) const {return !(*this<a || *this==a);}
    point operator+(const point &a) const {return {x+a.x,y+a.y};}
    point operator-(const point &a) const {return {x-a.x,y-a.y};}
    point operator-() const {return {-x,-y};}
    point operator*(const T k) const {return {k*x,k*y};}
    point operator/(const T k) const {return {x/k,y/k};}
    T operator*(const point &a) const {return x*a.x+y*a.y;}  // 点积
    T operator^(const point &a) const {return x*a.y-y*a.x;}  // 叉积,注意优先级
    int toleft(const point &a) const {const auto t=(*this)^a; return (t>eps)-(t<-eps);}  // to-left 测试
    T len2() const {return (*this)*(*this);}  // 向量长度的平方
    T dis2(const point &a) const {return (a-(*this)).len2();}  // 两点距离的平方

    // 涉及浮点数
    long double len() const {return sqrtl(len2());}  // 向量长度
    long double dis(const point &a) const {return sqrtl(dis2(a));}  // 两点距离
    long double ang(const point &a) const {return acosl(max(-1.0l,min(1.0l,((*this)*a)/(len()*a.len()))));}  // 向量夹角
    point rot(const long double rad) const {return {x*cos(rad)-y*sin(rad),x*sin(rad)+y*cos(rad)};}  // 逆时针旋转(给定角度)
    point rot(const long double cosr,const long double sinr) const {return {x*cosr-y*sinr,x*sinr+y*cosr};}  // 逆时针旋转(给定角度的正弦与余弦)
};
using  Point  = point<point_t>;
// 直线
template<typename T> struct line
{
    point<T> p,v;  // p 为直线上一点,v 为方向向量

    bool operator==(const line &a) const {return v.toleft(a.v)==0 && v.toleft(p-a.p)==0;}
    int toleft(const point<T> &a) const {return v.toleft(a-p);}  // to-left 测试

    // 涉及浮点数
    long double dis(const point<T> &a) const {return abs(v^(a-p))/v.len();}  // 点到直线距离
    T op(const point<T> &a){return abs(v^(a-p))*abs(v^(a-p));};
};

using Line=line<point_t>;
ll solve()
{
    int n;cin>>n;
    Point o;
    ll r;
    cin>>o.x>>o.y>>r;
    vector<Point> a(n*2);
    for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y,a[i+n]=a[i];
    auto check = [&](int i,int j){
        if(j>i+n)return false;
        if((a[j]-a[i]).toleft(o-a[i])<0)return false;
        Line l{a[i],a[j]-a[i]};
        return l.op(o)>=r*r*l.v.len2();
    };
    ll ans=0,now=0;
    for(int i=0,j=1;i<n;i++){
        while(check(i,j+1)){
            now+=abs((a[j+1]-a[i])^(a[j]-a[i]));
            j++;
        }
        // cout<<"i="<<i<<" j="<<j<<" now="<<now<<endl;
        ans=max(ans,now);
        now-=abs((a[i]-a[i+1])^(a[j]-a[i+1]));
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;cin>>T;while(T--)cout<<solve()<<"\n";
}

詳細信息

answer.code: In function ‘ll solve()’:
answer.code:93:21: error: call of overloaded ‘abs(__int128)’ is ambiguous
   93 |             now+=abs((a[j+1]-a[i])^(a[j]-a[i]));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/13/cstdlib:81:
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
answer.code:98:17: error: call of overloaded ‘abs(__int128)’ is ambiguous
   98 |         now-=abs((a[i]-a[i+1])^(a[j]-a[i+1]));
      |              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
answer.code: In instantiation of ‘T line<T>::op(const point<T>&) [with T = __int128]’:
answer.code:88:20:   required from here
answer.code:72:39: error: call of overloaded ‘abs(__int128)’ is ambiguous
   72 |     T op(const point<T> &a){return abs(v^(a-p))*abs(v^(a-p));};
      |                                    ~~~^~~~~~~~~
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
answer.code:72:52: error: call of overloaded ‘abs(__int128)’ is ambiguous
   72 |     T op(const point<T> &a){return abs(v^(a-p))*abs(v^(a-p));};
      |                                                 ~~~^~~~~~~~~
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~