QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#597176#9434. Italian Cuisineucup-team4906#WA 0ms3780kbC++142.6kb2024-09-28 17:13:402024-09-28 17:13:41

Judging History

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

  • [2024-09-28 17:13:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3780kb
  • [2024-09-28 17:13:40]
  • 提交

answer

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

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) {}
};
db dis(point a, point b) {return sqrt(1.0 * (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;

db dis_point_line(point p, line v) {
    return fabs(1.0 * cross(p - v.p1, v.p2 - v.p1) / dis(v.p1, v.p2));
}
int line_circle_relation(line v, circle C) {
    db dst = dis_point_line(C.c, v);
    if(sgn(dst - C.r) < 0) return 0;
    else if(sgn(dst - C.r) == 0) 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);
    int t; cin >> t;
    while(t --) {
        int n; cin >> n;
        int xx, yy, r; cin >> xx >> yy >> r;
        C = circle(xx, yy, r);
        vector<point> a;
        F(i, 1, n) {
            int 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 ++) {
            if(i == j) {
                j = (j + 1) % n;
                now = 0;
            } else {
                now += cross(a[j], a[i]);
            }
            while((j + 1) % n != i && line_circle_relation(line(a[i], a[j]), C)) {
                if(point_line_relation(C.c, line(a[i], a[j])) == 1) {
                    res = max(res, sum - now);
                } else {
                    res = max(res, now);
                }
                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;
            }
            now -= cross(a[i], a[(i + 1) % n]), now -= cross(a[j], a[i]);
        }
        cout << res << "\n";
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'