QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#609166#9434. Italian CuisineRosmontispesWA 18ms3852kbC++202.0kb2024-10-04 11:02:062024-10-04 11:02:07

Judging History

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

  • [2024-10-04 11:02:07]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3852kb
  • [2024-10-04 11:02:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct Point{
    long long x,y;
    Point(long long a = 0,long long b = 0){x = a,y = b;}
};
Point operator - (Point a,Point b){
    return Point(a.x - b.x,a.y - b.y);
}
long long Dot(Point a,Point b){
    return a.x * b.x + a.y * b.y;
}
long long Cross(Point a,Point b){
    return a.x*b.y - a.y*b.x;
}
long long Cross(Point sp,Point ep,Point op){
    return (sp.x - op.x) * (ep.y - op.y) - (ep.x - op.x) * (sp.y - op.y);
}

long long dis(Point a,Point b){
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
int judge(Point A,Point B,Point C,long long r){
    if(dis(A,B) == 0)
        return dis(B,C) >= r * r;
    if(Dot(B - A,C - A) < 0)
        return dis(A,C) >= r * r;
    if(Dot(A - B,C - B) < 0)
        return dis(B,C) >= r * r;
    return Cross(B - A,C - A) * Cross(B - A,C - A) >= r * r * dis(B,A);
}

void solve(){
    int n; 
    cin>>n;
    long long cx,cy,r;
    cin>>cx>>cy>>r;
    Point cir(cx,cy);
    vector<Point>poi(n);
    for(int i = 0;i < n;i ++){
        long long x,y;
        cin>>x>>y;
        poi[i] = Point(x,y);
    }
    int j = 0;
    long long S = 0;
    long long ans = 0;
    for(int st = 0;st < n;st ++){
        if(j == st){
            j = j + 1 >= n?(j + 1 - n):j + 1;
            S = Cross(poi[st],poi[j]);
        }
        int nex = j + 1 >= n?(j + 1 - n):j + 1;
        while(j != st){
            if(Cross(poi[j],cir,poi[st]) * Cross(poi[nex],cir,poi[st]) <= 0)
                break;
            if(!judge(poi[st],poi[nex],cir,r))
                break;
            S += Cross(poi[j],poi[nex]);
            j = nex;
            nex = j + 1 >= n?(j + 1 - n):j + 1;
        }
        ans = max(ans,S + Cross(poi[j],poi[st]));
        nex = st + 1 >= n?(st + 1 - n):st + 1;
        S -= Cross(poi[st],poi[nex]);
    }
    cout<<ans<<"\n";
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T --)
        solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

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: 0ms
memory: 3576kb

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: 0
Accepted
time: 13ms
memory: 3852kb

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:

5093
3086
2539
668
3535
7421
4883
5711
5624
1034
2479
3920
4372
2044
4996
5070
2251
4382
4175
1489
1154
3231
4038
1631
5086
14444
1692
6066
687
1512
4849
5456
2757
8341
8557
8235
1013
5203
10853
6042
6300
4480
2303
2728
1739
2187
3385
4266
6322
909
4334
1518
948
5036
1449
2376
3180
4810
1443
1786
47...

result:

ok 6666 numbers

Test #4:

score: -100
Wrong Answer
time: 18ms
memory: 3852kb

input:

6660
19
-689502500 -712344644 121094647
-534017213 -493851833
-578925616 -506634533
-663335128 -540066520
-748890119 -585225068
-847722967 -641694086
-916653030 -716279342
-956235261 -766049951
-1000000000 -836145979
-963288744 -923225928
-948140134 -944751289
-920681768 -972760883
-872492254 -10000...

output:

42454525447688645
53085313122339640
22028875391955615
2830698619245868
7743479878276068
53171057323874107
5099669152823584
10406144193189100
42940544135023044
22391622080548020
8764020390012605
119555444710683988
11563539414024344
9001722648548373
28242242813209813
6715672727147745
808034684881975
1...

result:

wrong answer 1st numbers differ - expected: '117285633945667137', found: '42454525447688645'