QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600287#9434. Italian Cuisinemojo__hugoWA 0ms3784kbC++202.0kb2024-09-29 15:42:452024-09-29 15:42:47

Judging History

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

  • [2024-09-29 15:42:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-09-29 15:42:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define ull unsigned long long
using PII = pair<int, int>;
using ld = long double;
const int N = 1e5 + 5, M = 998244353;

typedef __int128 lll;
istream &operator>>(istream &cin, lll &x) { x=0; static string s; cin>>s; for (char c:s) x=x*10+(c-'0'); return cin; }
ostream &operator<<(ostream &cout, lll x) { static char s[60]; int tp=1; s[0]='0'+(x%10); while (x/=10) s[tp++]='0'+(x%10); while (tp--) cout<<s[tp]; return cout; }

struct P {
    lll x, y;
}a[N];

ll S(P A, P B, P C) {
    return abs((ll)((B.x - A.x) * (C.y - A.y) - (C.x - A.x) * (B.y - A.y)));
}

lll cross(const P& u, const P& v) {
    lll tmp = u.x * v.y - u.y * v.x;
    return tmp;
}

struct line {lll a, b, c;};
line get(P A, P B) {
    return { (A.y - B.y),(B.x - A.x),(A.x * B.y - B.x * A.y) };
}
P get1(P A,P B){
    return { B.x - A.x,B.y - A.y };
}

lll x, y, r, n; 
P o;
bool chk(int i, int j) {
    line L = get(a[i], a[j]);
    lll tmp = L.a * x + L.b * y + L.c;
    if (tmp * tmp < r * r * (L.a * L.a + L.b * L.b))return 0;
    // cout << 233 << endl;
    P O = get1(a[i], o);
    P A = get1(a[i], a[(j - 1 + n) % n]);
    P B = get1(a[i], a[j]);
    if (cross(A, B) == 0)return 1;
    if (cross(A, O) * cross(B, O) < 0)return 0;
    return 1;
}
void solve() {
    cin >> n;
    cin >> x >> y >> r;
    o = { x,y };
    for (int i = 0;i < n;i++) {
        cin >> a[i].x >> a[i].y;
    }
    ll res = 0, j = 1, ans = 0;
    // cout << chk(0, 4) << endl;
    for (int i = 0;i < n;i++) {
        while (chk(i, (j + 1) % n)) {
            j++;
            j %= n;
            res += S(a[i], a[(j - 1 + n) % n], a[j]);
        }
        // cout << i<<' '<<j<<' '<<res << endl;
        ans = max(ans, res);
        res -= S(a[i], a[(i + 1) % n], a[j]);
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int tt = 1;
    // cout << fixed << setprecision(10);
    cin >> tt;
    while (tt--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

1478754091839323900

result:

wrong answer 1st numbers differ - expected: '0', found: '1478754091839323900'