QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#598214 | #9434. Italian Cuisine | ucup-team4906# | WA | 0ms | 3576kb | C++14 | 3.0kb | 2024-09-28 20:51:52 | 2024-09-28 20:51:54 |
Judging History
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) {}
};
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;
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(point_line_relation(C.c, line(a[i], a[j])) == 1) {
if(now != 0) res = max(res, sum - now);
// res = max(res, sum - now);
} else {
if(now != sum) res = max(res, now);
// 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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
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:
12 24 0
result:
wrong answer 1st numbers differ - expected: '5', found: '12'