QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#595602#9434. Italian Cuisineucup-team4479#WA 1ms5196kbC++232.3kb2024-09-28 14:05:032024-09-28 14:05:03

Judging History

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

  • [2024-09-28 14:05:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5196kb
  • [2024-09-28 14:05:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=100005;
const long double eps=1e-6;
int n;
struct Point
{
    long long x,y;
    Point(long long _x=0,long long _y=0):x(_x),y(_y){}
    friend Point operator+(const Point &a,const Point &b)
    {
        return Point(a.x+b.x,a.y+b.y);
    }
    friend Point operator-(const Point &a,const Point &b)
    {
        return Point(a.x-b.x,a.y-b.y);
    }
    friend bool operator==(const Point &a,const Point &b)
    {
        return a.x==b.x&&a.y==b.y;
    }
    Point operator*(const long long &v)const
    {
        return Point(x*v,y*v);
    }
    Point operator/(const long long &v)const
    {
        return Point(x/v,y/v);
    }
    friend long long dot(const Point &a,const Point &b)
    {
        return a.x*b.x+a.y*b.y;
    }
    friend long long cross(const Point &a,const Point &b)
    {
        return a.x*b.y-a.y*b.x;
    }
}p[N];
struct Line
{
    Point a,b;
    Line(const Point &_a,const Point &_b):a(_a),b(_b){}
    long double distance(const Point &p)const
    {
        long long area=abs(cross(b-p,a-p));
        long double length = sqrtl((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y));
        return area/length;
    }
};
void solve()
{
    cin>>n;
    Point o;
    int r;
    cin>>o.x>>o.y>>r;
    for(int i=1;i<=n;i++)
        cin>>p[i].x>>p[i].y;
    long long ans=0;
    long long sum=0;
    for(int i=1,j=1;i<=n;i++)
    {
        while(cross(p[j]-p[i],o-p[i])>=0&&(p[i]==p[j]||Line(p[i],p[j]).distance(o)>=r-eps)) sum+=cross(p[j],p[j%n+1]),j=j%n+1;
        int lstj=j-1;
        if(lstj==0) lstj=n;
        ans=max(ans,sum-cross(p[lstj],p[j])+cross(p[lstj],p[i]));
        sum-=cross(p[i],p[i%n+1]);
    }
    reverse(p+1,p+n+1);
    sum=0;
    for(int i=1,j=1;i<=n;i++)
    {
        while(cross(p[j]-p[i],o-p[i])<=0&&(p[i]==p[j]||Line(p[i],p[j]).distance(o)>=r-eps)) sum+=-cross(p[j],p[j%n+1]),j=j%n+1;
        int lstj=j-1;
        if(lstj==0) lstj=n;
        ans=max(ans,sum+cross(p[lstj],p[j])-cross(p[lstj],p[i]));
        sum-=-cross(p[i],p[i%n+1]);
    }
    cout<<ans<<"\n";
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int T;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 5140kb

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'