QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618887#9434. Italian CuisineEmotion_ZCompile Error//C++172.5kb2024-10-07 11:23:142024-10-07 11:23:16

Judging History

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

  • [2024-10-07 11:23:16]
  • 评测
  • [2024-10-07 11:23:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define deg( x ) cout<<""#x"="<<x<<endl
#define endl '\n'

const int N=1e5+10;
const __int128 ONE=1;

struct node //结构体存点坐标;
{
    int x,y;
    friend bool operator<( const node& a , const node& b )//自定义排序;
    {
        if( a.x!=b.x ) return a.x<b.x;
        return a.y<b.y;
    }
} A[ N ];

node B[ N ];

__int128 cross( node a , node b , node c ){
    return ( ONE*b.x-ONE*a.x )*( ONE*c.y-ONE*a.y )-( ONE*b.y-ONE*a.y )*( ONE*c.x-ONE*a.x );
}

bool pan( int sx , int sy , int r , node a , node b ){
    __int128 s=cross( a , b , { sx , sy } );
    if( s <= 0 ) return false;

    __int128 ss=ONE*s*s;
    __int128 len=( ONE*a.x-ONE*b.x )*( ONE*a.x-ONE*b.x )+( ONE*b.y-ONE*a.x )*( ONE*b.y-ONE*a.y );
    if( ss >= ONE*len*r*r ) return true;
    return false;
}

void solve(){
    int n;
    cin>>n;

    int sx,sy,r;
    cin>>sx>>sy>>r;

    for( int i=1; i<=n; i++ ){
        cin>>A[ i ].x>>A[ i ].y;
        B[ i ]=A[ i ];
    }

//    int idx=0;
//    A[ ++idx ]=B[ 1 ];
//    A[ ++idx ]=B[ 2 ];
//    for( int i=3; i<=n; i++ ){
//        if( cross( A[ idx-1 ] , A[ idx ] , B[ i ] )==0 ) idx--;
//        A[ ++idx ]=B[ i ];
//    }
//
//    while( cross( A[ idx ], A[ 1 ], A[ 2 ] ) == 0 ) {
//        A[ 1 ]=A[ idx ];
//        idx--;
//    }
//    n=idx;

    int ans=0;
    int ne=1;
    int cnt=0;
    for( int i=1; i<=n; i++ ){
        if( ne==i ) ne=i+1;
        if( ne==n+1 ) ne=1;

        while( 1 ){
            if( pan( sx , sy , r , A[ i ] , A[ ne ] ) ){
                //cout<<i<<"->"<<ne<<endl;
                int di=ne-1;
                if( di==0 ) di=n;
                //cout<<"+"<<i<<" "<<di<<" "<<ne<<endl;
                //cout<<"++"<<cross( A[ i ] , A[ di ] , A[ ne ] )<<endl;
                cnt+=abs( cross( A[ i ] , A[ di ] , A[ ne ] ) );

                ne++;
                if( ne==n+1 ) ne=1;
            }
            else{
                ne--;
                if( ne==0 ) ne=n;
                break;
            }
        }

        ans=max( ans , cnt );
        int tt=i+1; if( tt>n ) tt=1;
        cnt-=abs( cross( A[ ne ] , A[ i ] , A[ tt ] ) );
        ne++; if( ne==n+1 ) ne=1;
    }

    cout<<ans<<endl;
}

signed main() {
    ios::sync_with_stdio( 0 );
    cin.tie( 0 ); cout.tie( 0 );

    int T=1;
    cin>>T;

    while( T-- ){
        solve();
    }

    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:78:25: error: call of overloaded ‘abs(__int128)’ is ambiguous
   78 |                 cnt+=abs( cross( A[ i ] , A[ di ] , A[ ne ] ) );
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:92:17: error: call of overloaded ‘abs(__int128)’ is ambiguous
   92 |         cnt-=abs( cross( A[ ne ] , A[ i ] , A[ tt ] ) );
      |              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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); }
      |   ^~~