QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603611#9434. Italian CuisineSound_Medium#WA 1ms5904kbC++231.9kb2024-10-01 17:47:502024-10-01 17:47:51

Judging History

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

  • [2024-10-01 17:47:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5904kb
  • [2024-10-01 17:47:50]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N=2e5+10;
const double eps=1e-13;
int n;
int x,y;int  r;
struct Point{
    int x,y;
    Point(){}
    Point(int xx,int yy){
        x=xx,y=yy;
    }
    Point operator+(const Point &o)const{
        return Point(x+o.x,y+o.y);
    }
    Point operator-(const Point &o)const{
        return Point(x-o.x,y-o.y);
    }
    int operator*(const Point&o)const{
        return x*o.x+y*o.y;
    }
    int operator^(const Point&o)const{
        return x*o.y-y*o.x;
    }
    bool operator<(const Point&o)const{
        if(x!=o.x)return x<o.x;
        return y<o.y;
    }
}p[N],st[N];
int xmult(Point p1,Point p2,Point p0){
    return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
bool check(Point x,Point a,Point b){
    if((x-a)*(x-a)<=r*r||(x-b)*(x-b)<=r*r)return 1;
    Point t=x;
    t.x+=a.y-b.y;
    t.y+=b.x-a.x;
    int k=xmult(x,a,b);
    return xmult(a,x,t)<0&&k*k<r*r*((b-a)*(b-a));
}
void solve () {
    cin>>n;
    cin>>x>>y>>r;
    p[0]={x,y};
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        p[i]=p[n+i]={x,y};
    }
    int maxx=0,res;
    vector<int>pre(2*n+2,0);
    for(int i=2;i<=2*n;i++){
        pre[i]=pre[i-1]+(p[i-1]^p[i]);
    }
    auto f=[&](int st,int ed)->bool {
        {}
        if(((p[ed]-p[st])^(p[0]-p[st]))>0&&!check(p[0],p[st],p[ed])){
            return 1;
        }
        return 0;
    };
    for(int i=1;i<=n;i++){
        int l=i+1,r=n+i-1;
        while(l<r){
            int mid=l+r+1>>1;
            if(f(i,mid))l=mid;
            else r=mid-1;
        }

        maxx=max(maxx,abs(pre[l]-pre[i]+(p[l]^p[i])));
    }
    cout<<maxx<<'\n';
}

signed main () {
    ios::sync_with_stdio (false);
    cin.tie (nullptr);

    int T = 1;
    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: 5612kb

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

input:

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

output:

1238514776782540316

result:

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