QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#624257 | #9434. Italian Cuisine | Tecy | WA | 20ms | 3860kb | C++20 | 8.2kb | 2024-10-09 15:21:37 | 2024-10-09 15:21:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void error() {
cerr << endl;
}
template<class T, class... Args>
void error(T val, Args... args) {
cerr << val << " ";
error(args...);
}
const long double eps = 1e-9;
struct point {
long double x;
long double y;
point(long double _x = 0, long double _y = 0){
x = _x;
y = _y;
}
long double square_length() const {
return x * x + y * y;
}
//模长
long double length() const {
return sqrtl(x * x + y * y);
}
friend point operator+(const point& lp, const point& rp){
return point(lp.x + rp.x, lp.y + rp.y);
}
friend point operator-(const point& lp, const point& rp){
return point(lp.x - rp.x, lp.y - rp.y);
}
friend point operator*(const point& p, const long double& k){
return point(p.x * k, p.y * k);
}
friend point operator*(const long double& k, const point& p){
return point(p.x * k, p.y * k);
}
friend point operator/(const point& p, const long double& k){
return point(p.x / k, p.y / k);
}
friend bool operator==(const point& lp, const point& rp){
return abs(lp.x - rp.x) < eps && abs(lp.y - rp.y) < eps;
}
friend bool operator!=(const point& lp, const point& rp){
return abs(lp.x - rp.x) > eps || abs(lp.y - rp.y) > eps;
}
};
//点乘
long double dot(const point& lp, const point& rp){
return lp.x * rp.x + lp.y * rp.y;
}
//叉乘
long double cross(const point& lp, const point& rp){
return lp.x * rp.y - lp.y * rp.x;
}
long double square_distance(const point& lp, const point& rp){
return (lp.x - rp.x) * (lp.x - rp.x) + (lp.y - rp.y) * (lp.y - rp.y);
}
//两点距离
long double distance(const point& lp, const point& rp){
return sqrtl((lp.x - rp.x) * (lp.x - rp.x) + (lp.y - rp.y) * (lp.y - rp.y));
}
const long double PI = 3.141592653589793;
//矢量旋转 逆时针旋转 o (弧度制)
point rotate(const point& v, long double o){
long double x = v.x * cos(o) - v.y * sin(o);
long double y = v.x * sin(o) + v.y * cos(o);
return point(x, y);
}
//点到直线的距离 p到lp--rp的距离
long double distance(const point& lp, const point& rp, const point& p){
point vl = rp - lp;
point vr = p - lp;
return cross(vl, vr) / vl.length();
}
//符号判断
int sign(long double x){
if(x > eps){//正数
return 1;
}
if(x < -eps){//负数
return -1;
}
return 0;
}
//点在线段上(含端点) lp rp 为线段端点
bool on_segment(const point& lp, const point& rp, const point& p){
point vl = rp - lp;
point vr = p - lp;
long double sv = cross(vl, vr);
if(sign(sv) != 0){//不在直线上
return false;
}
long double cv = dot(vl, vr);
if(sign(cv) == -1){//在线段外
return false;
}
return vr.length() <= vl.length();
}
//点在线段上(不含端点) lp rp 为线段端点
bool on_segment_strict(const point& lp, const point& rp, const point& p){
return on_segment(lp, rp, p) && lp != p && rp != p;
}
//求垂点 p到直线lp--rp的垂点
point foot(const point& lp, const point& rp, const point& p){
point vl = rp - lp;
point vr = p - lp;
long double k = dot(vl, vr) / vl.length() / vl.length();
return lp + vl * k;
}
//点 p 是否在直线 lp-rp 上
bool on_line(const point& lp, const point& rp, const point& p) {
point vl = rp - lp;
point vr = p - lp;
return sign(cross(vl, vr)) == 0;
}
//点 p 是否射线 lp->rp 上
bool on_ray(const point& lp, const point& rp, const point& p) {
point vl = rp - lp;
point vr = p - lp;
return sign(cross(vl, vr)) == 0 && sign(dot(vl, vr)) != -1;
}
//两直线交点
point intersect(const point& flp, const point& frp, const point& slp, const point& srp){
point sf = flp - slp;
point vf = frp - flp;
point vs = srp - slp;
long double k = cross(sf, vs) / cross(vs, vf);
return flp + vf * k;
}
// 两直线是否平行 (直线的两点不能相同) / 需要考虑直线重合的情况
bool parallel(const point& flp, const point& frp, const point& slp, const point& srp) {
point vf = frp - flp;
point vs = srp - slp;
return sign(cross(vs, vf)) == 0;
}
// 直线是否重合
bool equal(const point& flp, const point& frp, const point& slp, const point& srp) {
point vf = frp - flp;
point vs = srp - slp;
point sf = flp - slp;
return sign(cross(vs, vf)) == 0 && sign(cross(sf, vs)) == 0;
}
struct circle {
point o;
long double r;
};
//垂直平分线 两点式
pair<point, point> perpendicular(const point& lp, const point& rp){
return { (lp + rp) / 2, (lp + rp) / 2 + rotate(rp - lp, PI / 2) };
}
//三点确定圆 (外接圆)
circle cover(const point& a, const point& b, const point& c){
auto lp = perpendicular(a, b);
auto rp = perpendicular(a, c);
point o = intersect(lp.first, lp.second, rp.first, rp.second);
return { o, distance(o, a) };
}
// 三角形内切圆, 需要三点不共线
circle inner (const point& a, const point& b, const point& c) {
point ab = b - a;
point ac = c - a;
point ao = (ab / ab.length() + ac / ac.length()) / 2 + a;
point ba = a - b;
point bc = c - b;
point bo = (ba / ba.length() + bc / bc.length()) / 2 + b;
auto o = intersect(a, ao, b, bo);
return { o, abs(distance(a, b, o)) };
}
// 求直线与圆的交点 保证有交点的情况下
pair<point, point> intersect(const point& lp, const point& rp, const circle& c) {
point ft = foot(lp, rp, c.o);
long double oft = distance(c.o, ft);
long double k = sqrtl(c.r * c.r - oft * oft);
point lr = (rp - lp) * k / distance(lp, rp);
return { ft + lr, ft - lr };
}
// 求两圆的交点, 保证有交点
pair<point, point> intersect(const circle& lc, const circle& rc) {
long double d = distance(lc.o, rc.o);
long double k = ((lc.r * lc.r - rc.r * rc.r) / d + d) / 2;
long double o = acos(k / lc.r);
point lr = rc.o - lc.o;
point lu = rotate(lr, o);
lu = lu / lu.length() * lc.r;
point ld = rotate(lr, -o);
ld = ld / ld.length() * lc.r;
return { lc.o + lu, lc.o + ld };
}
bool isLeft(const point& lp, const point& rp, const point& p) {
return sign(cross(rp - lp, p - lp)) > 0;
}
bool isLeft(const point& lp, const point& rp, const circle& cle) {
return sign(abs(distance(lp, rp, cle.o)) - cle.r) > 0 && isLeft(lp, rp, cle.o);
}
long double triangle(const point& a, const point& b, const point& c) {
if (a == b || a == c || b == c) {
return 0;
}
long double d = abs(distance(b, c, a));
return d * (b - c).length() / 2;
}
/*
auto convex = Andrew(vp);
int m = convex.size();
long double d = 0;
for(int i = 0, j = 1;i < m;i++){
while(cross(convex[(i + 1) % m] - convex[i], convex[j] - convex[i]) < cross(convex[(i + 1) % m] - convex[i], convex[(j + 1) % m] - convex[i])){
j = (j + 1) % m;
}
d = max(d, max(distance(convex[i], convex[j]), distance(convex[(i + 1) % m], convex[j])));
}
*/
inline void Tecy() {
using i64 = int64_t;
i64 n;
cin >> n;
i64 ox, oy, r;
cin >> ox >> oy >> r;
circle cle;
cle.o.x = ox;
cle.o.y = oy;
cle.r = r;
vector<point> cx(n);
vector<i64> px(n), py(n);
for (int i = 0; i < n; i++) {
cin >> px[i] >> py[i];
cx[i].x = px[i];
cx[i].y = py[i];
}
long double ans = 0;
long double tmp = 0;
for (int i = 0, j = 0; i < n; i++) {
while (isLeft(cx[i], cx[(j + 1) % n], cle)) {
tmp += triangle(cx[i], cx[j % n], cx[(j + 1) % n]);
j += 1;
// error(i, j, (j + 1) % n, triangle(cx[i], cx[j], cx[(j + 1) % n]));
}
// error(i, j, tmp);
ans = max(ans, tmp);
tmp -= triangle(cx[i], cx[(i + 1) % n], cx[j % n]);
j = max(j, i + 1);
}
cout << (long long) round(ans * 2) << "\n";
}
int main() {
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T--) {
Tecy();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
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: 3540kb
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: 20ms
memory: 3780kb
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 2862 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:
wrong answer 2nd numbers differ - expected: '3086', found: '2862'