QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623364#9434. Italian CuisineTienKhoiWA 1ms3720kbC++172.3kb2024-10-09 11:32:212024-10-09 11:32:21

Judging History

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

  • [2024-10-09 11:32:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-10-09 11:32:21]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define double long double
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define bit(x, y) ((x) >> (y)) & 1
#define pb push_back
#define ll long long
#define ii pair<int, int>
#define f first
#define s second
#define M 1000000007
using namespace std;
const int N = 1e5 + 5;
void Inp()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen(".inp", "r"))
    {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
}
int x[N], y[N];
const double esp = 0.000000001;
bool check(int xc, int yc, double r, int xa, int ya, int xb, int yb) {
    double s = abs((xb - xa) * (yc - ya) - (xc - xa) * (yb - ya));
    double d = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
    d = sqrtl(d);
    double h = s / d;
    //cout << h << '\n';
    if (r <= h) return true;
    return false;
}
int S(int xa, int ya, int xb, int yb, int xc, int yc) {
    return abs((xb - xa) * (yc - ya) - (xc - xa) * (yb - ya));
}
bool inside(int xa, int ya, int xb, int yb, int xc, int yc, int xd, int yd) {
    return (S(xa, ya, xb, yb, xc, yc) + S(xa, ya, xb, yb, xd, yd) + S(xa, ya, xc, yc, xd, yd) == S(xb, yb, xc, yc, xd, yd));
}
void solve()
{
    int n;
    cin >> n;
    int xc, yc, r;
    cin >> xc >> yc >> r;
    FOR(i, 1, n) {
        cin >> x[i] >> y[i];
    }
    FOR(i, n + 1, 2 * n) {
        x[i] = x[i -n];
        y[i] = y[i -n];
    }
    int ans = 0, cur = 0, j = 1;
    //cout << check(xc, yc, r, 0, 0, 1, 0) << '\n';
    
    FOR(i, 1, n) {
        if (j < i) {
            j = i;
            cur = 0;
        } else 
        if (i > 1) {
            cur -= x[i - 1] * y[i] - y[i - 1] * x[i];
        }
        while (j + 1 <= n + i - 1 && !inside(xc, yc, x[i], y[i], x[j], y[j], x[j + 1], y[j + 1]) && check(xc, yc, r, x[i], y[i], x[j + 1], y[j + 1])) {
            j++;
            cur += x[j - 1] * y[j] - y[j - 1] * x[j]; 
        }
        //cout << i << " " << j << " " << cur << '\n';
        ans = max(ans, abs(cur + x[j] * y[i] - y[j] * x[i]));
    }
    cout << ans << '\n';
    
}
signed main()
{
    Inp();
    int Case = 1;
    cin >> Case;
    while (Case--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'