QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#608643#9434. Italian Cuisinereal_sigma_team#WA 1ms5700kbC++202.8kb2024-10-04 00:27:392024-10-04 00:27:39

Judging History

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

  • [2024-10-04 00:27:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5700kb
  • [2024-10-04 00:27:39]
  • 提交

answer

#include <bits/stdc++.h>
#include <immintrin.h>

using namespace std;

using ll = long long;
using ld = long double;
# define x first
# define y second
# define all(x) x.begin(), x.end()
# define rall(x) x.rbegin(), x.rend()

mt19937 mt(123);

void solve();
void init();

int32_t main() {
#ifndef LOCAL
    cin.tie(nullptr)->sync_with_stdio(false);
#endif
    init();
    cout << fixed << setprecision(10);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

void init() {}

#define int ll

struct line {
    ll a, b, c;
    line(const pair<int, int>& _a, const pair<int, int>& _b) {
        a = _a.y - _b.y;
        b = _b.x - _a.x;
        c = -(_a.x * a + _a.y * b);
    }
    ll operator[](const pair<int, int>& _a) {
        return a * _a.x + b * _a.y + c;
    }
    double norm() {
        return sqrt(a * a + b * b);
    }
};

double dist(const pair<int, int>& a, line b) {
    return abs(b[a] / b.norm());
}

ll cross_prod(const pair<int, int>& a, const pair<int, int>& b) {
    return 1ll * a.x * b.y - 1ll * a.y * b.x;
}

constexpr int N = 100100;
int n;
pair<int, int> a[N];
ll s[N];
__int128_t pref[N];

__int128_t get(int l, int r) {
    if (r >= l) {
        return pref[r] - pref[l] + cross_prod(a[r], a[l]);
    }
    return pref[n] - pref[l] + pref[r] + cross_prod(a[r], a[l]);
}

pair<int, int> operator - (const pair<int, int>& a, const pair<int, int>& b) {
    return {a.x - b.x, a.y - b.y};
}

void solve() {
    cin >> n;
    pair<int, int> c;
    int r;
    cin >> c.x >> c.y >> r;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].y;
    }
    pref[0] = 0;
    for (int i = 0; i < n; i++) {
        s[i] = cross_prod(a[i], a[(i + 1) % n]);
        pref[i + 1] = pref[i] + s[i];
    }
    int i2 = 30;
    for (int i = 0; i < n; i++) {
        {
            int nw = (i + 1) % n;
            for (int j = i2; j >= 0; j--) {
                int cur = (nw + (1 << j)) % n;
                if (get(i, cur) < get(i, nw)) {
                    continue;
                }
                if (cross_prod(a[cur] - a[i], c - a[i]) >= 0 && dist(c, line(a[i], a[cur])) >= r) {
                    nw = cur;
                }
            }
            ans = max<ll>(ans, get(i, nw));
        }
        {
            int nw = (i + 1) % n;
            for (int j = i2; j >= 0; j--) {
                int cur = (nw + (1 << j)) % n;
                if (get(i, cur) < get(i, nw)) {
                    continue;
                }
                if (cross_prod(a[cur] - a[i], c - a[i]) >= 0 || dist(c, line(a[i], a[cur])) < r) {
                    nw = cur;
                }
            }
            nw = (nw + 1) % n;
            ans = max<ll>(ans, pref[n] - get(i, nw));
        }
    }
    cout << ans << '\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5700kb

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

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'