QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#598086 | #9434. Italian Cuisine | ucup-team4906# | WA | 1ms | 3788kb | C++14 | 2.8kb | 2024-09-28 20:27:53 | 2024-09-28 20:27:53 |
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 long double db;
const db eps = 1e-12;
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 sqrtl(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]);
if(area < 0) area *= -1;
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);
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;
F(i, 0, n - 1) F(j, i + 2, n - 1) {
// if(i == j) continue;
if(line_circle_relation(line(a[i], a[j]), C)) {
vector<point> tmp;
F(k, i, j) tmp.push_back(a[k]);
if(tmp.size() < 3) continue;
int now = polygon_area(tmp, tmp.size());
if(now == 0 || now == sum) continue;
assert(point_line_relation(C.c, line(a[i], a[j])));
assert(point_line_relation(C.c, line(a[(i + 1) % n], a[j])));
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);
}
}
}
cout << (unsigned long long)res << "\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3648kb
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: 1ms
memory: 3788kb
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'