QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603586#9434. Italian CuisineSound_Medium#WA 13ms5972kbC++231.9kb2024-10-01 17:38:102024-10-01 17:38:11

Judging History

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

  • [2024-10-01 17:38:11]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:5972kb
  • [2024-10-01 17:38:10]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
// #define intlong double
using namespace std;
const int N=2e5+10;
int n;
int x,y;long double 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<=r*r||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: 5972kb

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

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: 13ms
memory: 5812kb

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:

11997
5228
5308
3593
7868
13142
8628
5711
7154
2930
3177
7134
8288
3610
12181
13259
5112
10141
11587
2268
2382
5344
6860
3691
7777
15756
3803
11309
1347
2643
5596
9598
6697
9767
13519
10585
1162
6190
11541
6650
6360
7507
5572
5704
2643
3833
4795
12688
7002
2667
12382
2426
6630
7895
2756
11458
4495
6...

result:

wrong answer 1st numbers differ - expected: '5093', found: '11997'