QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#673998#9434. Italian CuisineyixuanoctWA 0ms3924kbC++201.8kb2024-10-25 13:02:362024-10-25 13:02:37

Judging History

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

  • [2024-10-25 13:02:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3924kb
  • [2024-10-25 13:02:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N = 1e6 + 7;
const int INF = 0x3f3f3f3f3f3f3f3f;

struct Point {
    double x, y;

}pts[100007], cir;
double r;
double dis(double x1, double y1, double x2, double y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
double cross(Point p1, Point p2, Point p3) {
    return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);
}
Point intersection(Point u1, Point u2, Point v1, Point v2) {
    Point ret = u1;
    double t = ((u1.x - v1.x) * (v1.y - v2.y) - (u1.y - v1.y) * (v1.x - v2.x)) / ((u1.x - u2.x) * (v1.y - v2.y) - (u1.y - u2.y) * (v1.x - v2.x));
    ret.x += (u2.x - u1.x) * t;
    ret.y += (u2.y - u1.y) * t;
    return ret;
}
double ptoline(Point p, Point l1, Point l2) {
    Point t = p;
    t.x += l1.y - l2.y;
    t.y += l2.x - l1.x;
    Point ret = intersection(p, t, l1, l2);
    return dis(ret.x, ret.y, p.x, p.y);
}
double rotate(Point* pts, int n) {
    int p = 1;
    double ans = 0, dif = 0;
    pts[n] = pts[0];
    for (int i = 0;i < n;i++) {
        while (fabs(cross(pts[i], pts[i + 1], pts[p + 1])) >= fabs(cross(pts[i], pts[i + 1], pts[p])) && cross(pts[p], cir, pts[i]) * cross(pts[p + 1], cir, pts[i]) >= 0 && ptoline(cir, pts[i], pts[p + 1]) >= r) {
            dif += cross(pts[p], pts[p + 1], pts[i]);
            p = (p + 1) % n;
        }
        ans = max(ans, dif);
        dif -= cross(pts[i], pts[i + 1], pts[p]);
    }
    return ans;
}
void solve() {
    int n;
    cin >> n;
    cin >> cir.x >> cir.y >> r;
    for (int i = 0;i < n;i++) cin >> pts[i].x >> pts[i].y;
    cout << fixed << setprecision(0) << rotate(pts, n) << '\n';
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) solve();
}

详细

Test #1:

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

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

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'