QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#646588#9434. Italian CuisinexiachiWA 0ms3708kbC++201.6kb2024-10-17 01:44:022024-10-17 01:44:03

Judging History

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

  • [2024-10-17 01:44:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-10-17 01:44:02]
  • 提交

answer

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

struct Point {
    LL x, y;
    Point(LL x = 0, LL y = 0) : x(x), y(y) {}
    void input() {
        cin >> x >> y;
    }
    Point operator - (const Point& b) const {
        return Point(x - b.x, y - b.y);
    }
    LL operator ^ (const Point& b) const {
        return x * b.y - y * b.x;
    }
    LL length2() {
        return x * x + y * y;
    }
    long double length() {
        return sqrtl(x * x + y * y);
    }
};

int sgn(long double x) {
    if (abs(x) <= 1E-7) {
        return 0;
    }
    return x > 0 ? 1 : -1;
}


void solve() {
    int n;
    cin >> n;

    Point c;
    c.input();
    LL r;
    cin >> r;

    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        p[i].input();
    }
    LL sum = 0, res = 0;
    for (int i = 0, j = 1; i < n; i++) {
        while (true) {
            int k = (j + 1) % n;
            LL s = (p[k] - p[i]) ^ (c - p[k]);
            // if (s > 0 && s * s >= r * r * (p[k] - p[i]).length2()) {
            if (sgn(s / (p[k] - p[i]).length() - r) >= 0) {
                sum += (p[j] - p[i]) ^ (p[k] - p[j]);
                j = k;
            } else {
                break;
            }
        }
        res = max(res, sum);
        if (sum > 0) {
            // cout << i << ' ' << j << endl;
            int k = (i + 1) % n;
            sum -= (p[k] - p[i]) ^ (p[j] - p[k]);
        }
    }
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    int tt;
    cin >> tt;
    while (tt--) solve();

    return 0;
}

詳細信息

Test #1:

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

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

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'