QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#661321 | #9434. Italian Cuisine | wyhao | WA | 7ms | 5896kb | C++14 | 1.7kb | 2024-10-20 15:48:13 | 2024-10-20 15:48:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
typedef long long ll;
int n;
ll px[N],py[N];
ll cx,cy,r;
ll S[N];
ll area(ll x1,ll y1,ll x2,ll y2){
return x1*y2-x2*y1;
}
ll glr(int l,int r){
if(l<=r) return S[r]-S[l-1];
else return S[n]-S[l-1]+S[r];
}
inline int rd(){
int x=0,f=1;char c=getchar();
while(c<'0' or c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while('0'<=c and c<='9'){
x=(x<<1)+(x<<3)+(c-'0');
c=getchar();
}
return x*f;
}
bool check(ll x1,ll y1,ll x2,ll y2){
__int128 S1 = area(x1,y1,x2,y2);
S1*=S1;
__int128 S2 = ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
S2*=r*r;
return S1<S2;
}
void solve(){
// puts("aaa");
n=rd();
cx=rd();cy=rd();r=rd();
// puts("bbb");
for(int i=1;i<=n;i++){
px[i]=rd();py[i]=rd();
}
for(int i=1;i<=n;i++){
int j = i%n+1;
S[i] = abs(area(px[i]-cx,py[i]-cy,px[j]-cx,py[j]-cy))+S[i-1];
// printf("%lld\n",S[i]-S[i-1]);
}
int i=1,j=2;
ll ans=0;
for(;i<=n;i++){
while(!check(px[i]-cx,py[i]-cy,px[j%n+1]-cx,py[j%n+1]-cy) and area(px[j%n+1]-px[i],py[j%n+1]-py[i],cx-px[i],cy-py[i])>=0) j=j%n+1;
if(j==i%n+1){
j++;
continue;
}
// printf("%d %d\n",i,j);
ll ansk = glr(i,(j==1)?n:(j-1))-abs(area(px[i]-cx,py[i]-cy,px[j]-cx,py[j]-cy));
// printf("%lld %lld\n",glr(i,(j==1)?n:(j-1)),ansk);
ans = max(ans,ansk);
}
printf("%lld\n",ans);
}
int main(){
// freopen("ex.in","r",stdin);
int tests=rd();
while(tests--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5896kb
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: 3884kb
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: 7ms
memory: 3868kb
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 3086 2539 668 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 47...
result:
wrong answer 121st numbers differ - expected: '649', found: '1260'