QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#594910 | #9434. Italian Cuisine | ucup-team3555# | WA | 10ms | 19332kb | C++20 | 1.5kb | 2024-09-28 11:08:59 | 2024-09-28 11:09:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define bi __int128
const int N=1e6+5;
int n;
ll ans=0,res=0;
struct vec{
ll x,y;
vec(ll a=0,ll b=0){x=a,y=b;}
vec operator +(const vec &a) const{return vec(x+a.x,y+a.y);}
vec operator -(const vec &a) const{return vec(x-a.x,y-a.y);}
}a[N];
struct Cir{
vec a;
ll r;
Cir(vec x=vec(0,0),ll R=0){a=x,r=R; }
}C;
ll Dot(vec a,vec b){return a.x*b.x+a.y*b.y;}
ll Cro(vec a,vec b){return a.x*b.y-b.x*a.y;}
ll dcmp(ll x){return x==0?0:(x<0?-1:1);}
bool inter(int l,int r){
vec nw=a[r]-a[l];
ll s=Cro(nw,C.a-a[l]),len=Dot(nw,nw);
if((bi)s*s>(bi)C.r*C.r*len) return true;
return false;
}
bool chk(int l,int r){
if(dcmp(Cro(C.a-a[l],a[r]-a[l]))!=dcmp(Cro(C.a-a[l],a[(r+1)%n]-a[l]))) return false;
// cerr<<"chk: "<<l<<' '<<r<<endl;
return inter(l,(r+1)%n);
}
void SOLVE(){
cin>>n>>C.a.x>>C.a.y>>C.r;
for(int i=0;i<n;i++) cin>>a[i].x>>a[i].y;
ans=res=0;
for(int l=0,r=1;l<n;l++){
if(!inter(l,(l+1)%n)) continue;
if(!inter((l-1+n)%n,l)) r=(l+1)%n;
while(chk(l,r)) ans+=Cro(a[r]-a[l],a[(r+1)%n]-a[l]),r=(r+1)%n;
// cerr<<"l = "<<l<<' '<<r<<endl;
res=max(res,ans);
// cerr<<"ans = "<<ans<<endl<<endl;
ans-=Cro(a[l]-a[r],a[(l+1)%n]-a[r]);
}
cout<<res<<'\n';
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int _;cin>>_;
while(_--) SOLVE();
return 0;
}
/*
1
6
2 4 1
2 0
4 0
6 3
4 6
2 6
0 3
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 19252kb
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: 0
Accepted
time: 0ms
memory: 19332kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 10ms
memory: 19220kb
input:
6666 19 -142 -128 26 -172 -74 -188 -86 -199 -157 -200 -172 -199 -186 -195 -200 -175 -197 -161 -188 -144 -177 -127 -162 -107 -144 -90 -126 -87 -116 -86 -104 -89 -97 -108 -86 -125 -80 -142 -74 -162 -72 16 -161 -161 17 -165 -190 -157 -196 -154 -197 -144 -200 -132 -200 -128 -191 -120 -172 -123 -163 -138...
output:
5093 2862 2539 0 3535 7421 4883 5711 5624 1034 2479 3920 4372 2044 4996 5070 2251 4382 4175 1489 1154 3231 4038 1631 5086 14444 1692 6066 687 1512 4849 5456 2757 8341 8557 8235 1013 5203 10853 6042 6300 4480 2303 2728 1739 2187 3385 4266 6322 909 4334 1518 948 5036 1449 2376 3180 4810 1443 1786 4783...
result:
wrong answer 2nd numbers differ - expected: '3086', found: '2862'