QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#693343#9434. Italian CuisineEvanWA 1ms5876kbC++201.9kb2024-10-31 15:59:492024-10-31 15:59:58

Judging History

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

  • [2024-10-31 15:59:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5876kb
  • [2024-10-31 15:59:49]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define eps 1e-8
using namespace std;
const int N=100010;
struct point{
    ll x;
    ll y;
}P[N];
ll S[N];
ll S_s[N];
int n;
ll xr,yr,r;
ll M(point a,point b)
{
    return 1ll*a.x*b.y-1ll*b.x*a.y;
}
ll find_area(int left,int right)
{
    if(left<=right)return S_s[right-1]-S_s[left-1]-(M(P[left],P[right]));
    else{
        ll temp=S_s[n-1]-S_s[left-1]+S_s[right-1]+S[n];
        return temp-M(P[left],P[right]);
    }
}
double find_d(int left,int right)
{
    if(left==right)return sqrt(P[left].x*P[left].x+P[left].y*P[left].y)*1.00;
    double d1=sqrt((P[left].x-P[right].x)*(P[left].x-P[right].x)+(P[left].y-P[right].y)*(P[left].y-P[right].y))*1.00;
    double d=M(P[left],P[right])*1.00/d1;
    //printf("%d %d %lf %lf\n",left,right,d1,d);
    return d;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        scanf("%lld %lld %lld",&xr,&yr,&r);
        for(int i=1;i<=n;i++)
        {
            scanf("%lld %lld",&P[i].x,&P[i].y);
            P[i].x=(P[i].x)-xr*1ll;
            P[i].y=(P[i].y)-yr*1ll;
        }
        S_s[0]=0ll;
        for(int i=1;i<=n;i++)
        {
            if(i<n)S[i]=M(P[i],P[i+1]);
            else S[i]=M(P[i],P[1]);
            //printf("%lld\n",S[i]);
            S_s[i]=S_s[i-1]+S[i];
        }
        int curr=1;
        ll ans=0ll;
        for(int i=1;i<=n;i++)
        {
            while(find_d(i,(curr%n)+1)+eps>=1.00*r)
            {
                curr=(curr%n)+1;
                ans=max(1ll*ans,1ll*find_area(i,curr));
            }
        }
        curr=n;
        for(int i=n;i>=1;i--)
        {
            while(find_d(i,((curr+n-2)%n)+1)-eps<=-1.00*r)
            {
                curr=((curr+n-2)%n)+1;
                ans=max(ans*1ll,1ll*find_area(curr,i));
            }
        }
        printf("%lld\n",ans);
        
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5876kb

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: 1ms
memory: 5852kb

input:

1
6
0 0 499999993
197878055 -535013568
696616963 -535013568
696616963 40162440
696616963 499999993
-499999993 499999993
-499999993 -535013568

output:

286862654137719264

result:

wrong answer 1st numbers differ - expected: '0', found: '286862654137719264'