QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#598234#9434. Italian Cuisineucup-team4906#WA 18ms3624kbC++143.1kb2024-09-28 20:55:262024-09-28 20:55:26

Judging History

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

  • [2024-09-28 20:55:26]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3624kb
  • [2024-09-28 20:55:26]
  • 提交

answer

#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define int __int128
using namespace std;
typedef double db;
const db eps = 0;
typedef long long ll;

int sgn(db x) {
    if(fabs(x) <= eps) return 0;
    else return x < 0 ? -1 : 1;
}
struct point {
    int x, y;
    point() {}
    point (int x, int y) : x(x), y(y) {}
    point operator + (point B) {return point(x + B.x, y + B.y);}
    point operator - (point B) {return point(x - B.x, y - B.y);}
}; 
struct line {
    point p1, p2;
    line() {}
    line (point p1, point p2) : p1(p1), p2(p2) {}
};
int dis(point a, point b) {return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);}
int cross(point a, point b) {return a.x * b.y - a.y * b.x;}
int polygon_area(vector<point> &p, int n) {
    int area = 0;
    F(i, 0, n - 1) area += cross(p[i], p[(i + 1) % n]);
    return area;
}
struct circle {
    point c;
    int r;
    circle() {}
    circle(int x, int y, int _r) {c = point(x, y); r = _r;}  
} C;

pair<int, int> dis_point_line(point p, line v) {
    int tmp = cross(p - v.p1, v.p2 - v.p1);
    return {tmp * tmp, dis(v.p1, v.p2)};
}
int line_circle_relation(line v, circle C) {
    auto [x, y] = dis_point_line(C.c, v);
    int r = C.r;
    if(x < y * r * r) return 0;
    else if(x == y * r * r) return 1;
    else return 2;
}
int point_line_relation(point p, line v) {return sgn(cross(p - v.p1, v.p2 - v.p1));}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll t; cin >> t;
    while(t --) {
        ll n; cin >> n;
        ll xx, yy, r; cin >> xx >> yy >> r;
        C = circle(xx, yy, r);
        vector<point> a;
        F(i, 1, n) {
            ll x, y; cin >> x >> y;
            a.push_back(point(x, y));
        }
        int sum = polygon_area(a, n);
        int res = 0, now = 0;

        for(int i = 0, j = 0; i < n; i ++) {
            // cout << i << " " << j << " " << res << "!\n";
            if(i == j) {
                j = (j + 1) % n;
                now = 0;
            } else {
                now += cross(a[j], a[i]);
            }
            while(line_circle_relation(line(a[i], a[j]), C)) {
                if(now !=  0 && now != sum) {
                    if(point_line_relation(C.c, line(a[i], a[j])) == point_line_relation(a[(i + 1) % n], line(a[i], a[j]))) {
                        res = max(res, sum - now);
                    } else if(point_line_relation(C.c, line(a[i], a[j])) == -point_line_relation(a[(i + 1) % n], line(a[i], a[j]))) {
                        res = max(res, now);
                    }
                }
                if((j + 1) % n != i) {
                    now -= cross(a[j], a[i]), now += cross(a[j], a[(j + 1) % n]), now += cross(a[(j + 1) % n], a[i]); 
                    j = (j + 1) % n;
                } else break;
            }
            now -= cross(a[i], a[(i + 1) % n]), now -= cross(a[j], a[i]);
        }
        cout << (unsigned long long)res << "\n";
    }
    return 0;
}
/*
4
4
1 1 1
0 0
4 0 
4 4
0 4
4
1 3 1
0 0
4 0 
4 4
0 4
4
3 3 1
0 0
4 0 
4 4
0 4
4
3 1 1
0 0
4 0 
4 4
0 4
*/

詳細信息

Test #1:

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

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

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

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
4842
4874
1034
1642
3920
4372
2044
4996
5070
2251
4382
4175
1489
1154
3231
4019
1631
5086
12777
1692
6066
687
1512
4849
5456
2757
4700
8557
7008
862
4744
10041
5655
5101
4480
2303
2728
1739
2187
3385
4266
4116
909
4334
1518
948
5036
1449
2376
3180
4810
1443
1480
478...

result:

wrong answer 8th numbers differ - expected: '5711', found: '4842'