QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#661310#9434. Italian CuisinewyhaoTL 0ms0kbC++141.7kb2024-10-20 15:46:032024-10-20 15:46:05

Judging History

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

  • [2024-10-20 15:46:05]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-20 15:46:03]
  • 提交

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++){
        if(j<i%n+1) j=i%n+1;
        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) 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: 0
Time Limit Exceeded

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:


result: