QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#595672#9434. Italian Cuisineucup-team3548#WA 0ms3804kbC++171.9kb2024-09-28 14:13:242024-09-28 14:13:24

Judging History

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

  • [2024-09-28 14:13:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-09-28 14:13:24]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include <vector>
#include <cmath>
#include <cassert>
using namespace std;

using ll = long long;
using ld = long double;

struct Point {
    ll x, y;
    void read() {
        scanf("%lld %lld", &x, &y);
    }

    Point() {}

    Point(Point a, Point b) {
        x = b.x - a.x;
        y = b.y - a.y;
    }
};

using Vec = Point;

ll cha(Vec a, Vec b) {
    return a.x * b.y - b.x * a.y;
}

ld dis(Point a, Point b) {
    ld dx = a.x - b.x;
    ld dy = a.y - b.y;
    return sqrt(dx * dx + dy * dy);
}

void solve() {
    int n;
    scanf("%d", &n);

    ll r; // radius
    Point pina;
    pina.read();
    scanf("%lld", &r);

    auto jiao = [&](Point a, Point b) -> bool {
        ll area = cha(Vec(a, b), Vec(a, pina));
        ld h = static_cast<double>(area) / dis(a, b);
        return abs(h) <= static_cast<double>(r);
    };

    auto invxian = [&](Point a, Point b) -> bool {
        ll t = cha(Vec(a, b), Vec(a, pina));
        return t < 0;
    };


    vector<Point> conv(n);
    for (int i = 0; i < n; ++i) conv[i].read();

    int p = 0, q = 0;
    ll ans = 0, cur = 0;

    while (true) {
        while (true) {
            ans = max(ans, cur);
            int qq = (q + 1) % n;
            if (jiao(conv[p], conv[qq]) || invxian(conv[p], conv[qq])) {
                break;
            } else {
                ll t = cha(Vec(conv[p], conv[q]), Vec(conv[p], conv[qq]));
                assert(t >= 0);
                cur += t;
                q = qq;
            }
        }
        int pp = p + 1;
        if (pp == n) break;
        ll t = cha(Vec(conv[q], conv[p]), Vec(conv[q], conv[pp]));
        assert(t >= 0);
        cur -= t;
        assert(cur >= 0);
        p = pp;
    }

    printf("%lld\n", ans);
}

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'