QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595598#9434. Italian Cuisineucup-team3519#RE 0ms3612kbC++171.6kb2024-09-28 14:04:362024-09-28 14:04:37

Judging History

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

  • [2024-09-28 14:04:37]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3612kb
  • [2024-09-28 14:04:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define V vector
#define fi first
#define se second
typedef pair<int, int> pi;
typedef long long LL;

LL det(pi a, pi b) {
    return 1LL * a.fi * b.se - 1LL * a.se * b.fi;
}
LL dot(pi a, pi b) {
    return 1LL * a.fi * b.fi + 1LL * a.se * b.se;
}
LL sqr(int a) {
    return 1LL * a * a;
}
pi operator - (pi a, pi b) {
    return {a.fi - b.fi, a.se - b.se};
}
pi operator + (pi a, pi b) {
    return {a.fi + b.fi, a.se + b.se};
}
LL dis2(pi a) {
    return sqr(a.fi) + sqr(a.se);
}
LL closer(pi a, pi b, pi x, int r) {
    pi dir = (b - a);
    swap(dir.fi, dir.se);
    dir.fi = -dir.fi;

    return 1LL * r * r > sqr(dot(dir, a - x)) / dis2(dir);
}
void solve() {
    int n; cin >> n;
    pi o; cin >> o.fi >> o.se;
    int rad; cin >> rad;
    V<pi> a(n * 2);
    for(int i = 0; i < n; i++) cin >> a[i].fi >> a[i].se, a[i + n] = a[i];

    V<LL> sum(n * 2);
    for(int i = 1; i < 2 * n; i++) {
        sum[i] = sum[i - 1] + det(a[i - 1], a[i]);
    }

    LL ans = 0;

    int r = 0;
    for(int l = 0; l < n; l++) {
        while(!closer(a[l], a[r + 1], o, rad) && det(a[r + 1] - a[l], o - a[l]) > 0) r++;
        ans = max(ans, sum[r] - sum[l] + det(a[r], a[l]));
    }

    r = 2 * n - 1;
    for(int l = 2 * n - 1; l >= n; l--) {
        while(!closer(a[l], a[r - 1], o, rad) && det(a[r - 1] - a[l], o - a[l]) < 0) r--;
        ans = max(ans, sum[l] - sum[r] + det(a[l], a[r]));
    }

    // assert(ans % 2 == 0);

    cout << ans / 1 << endl;
}

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

詳細信息

Test #1:

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

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
Runtime Error

input:

1
6
0 0 499999993
197878055 -535013568
696616963 -535013568
696616963 40162440
696616963 499999993
-499999993 499999993
-499999993 -535013568

output:


result: