QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618892 | #9434. Italian Cuisine | Emotion_Z | WA | 0ms | 3708kb | C++17 | 2.6kb | 2024-10-07 11:25:29 | 2024-10-07 11:25:29 |
Judging History
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;
int te=cross( A[ i ] , A[ di ] , A[ ne ] );
if( te<0 ) te=-te;
cnt+=te;
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;
int te=cross( A[ ne ] , A[ i ] , A[ tt ] );
if( te<0 ) te=-te;
cnt-=te;
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
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
3 5 1 1 1 0 0 1 0 5 0 3 3 0 5 6 2 4 1 2 0 4 0 6 3 4 6 2 6 0 3 4 3 3 1 3 0 6 3 3 6 0 3
output:
5 24 0
result:
ok 3 number(s): "5 24 0"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3708kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
516201533178331388
result:
wrong answer 1st numbers differ - expected: '0', found: '516201533178331388'