QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602692#9434. Italian CuisineYcfhnndWA 0ms3616kbC++201.7kb2024-10-01 12:07:162024-10-01 12:07:18

Judging History

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

  • [2024-10-01 12:07:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-10-01 12:07:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;  
using i128 = __int128;

struct Point{
    i64 x, y;
};

i64 cross(const Point &a, const Point &b){
    return a.x * b.y - a.y * b.x;
}

i64 dot(const Point &a, const Point &b){
    return a.x * b.x + a.y * b.y;
}

i64 mul(const Point &a){
    return a.x * a.x + a.y * a.y;
}

Point operator -(const Point &a, const Point &b){
    return {a.x - b.x, a.y - b.y};
}

void solve(){
    int n;
    cin >> n;

    Point o;
    i64 r;
    cin >> o.x >> o.y >> r;

    vector<Point>p(n);
    for (int i = 0;i < n;i ++){
        cin >> p[i].x >> p[i].y;
    }

    i64 ans = 0;
    auto work = [&](int x){
        i64 res = 0;
        for (int l = 0, r = l + 1;l < n;l ++){
            while (1){
                int rr = r % n + 1;
                i64 s = cross(p[rr] - p[l], o - p[l]);
                if (x == 1){
                    if (s <= 0) break;
                }else{
                    if (s >= 0) break;
                }
                if (s * s < mul(p[rr] - p[l]) * r * r){
                    break;
                }

                res += cross(p[r] - p[l], p[rr] - p[l]);
                r = rr;
            }
            ans = max(ans, abs(res));
            // cerr << l << " " << r << " " << res << " " << ans << "\n";
            int ll = l % n + 1;
            res -= cross(p[r] - p[l], p[r] - p[ll]);
        }
    };   
    work(1);
    reverse(p.begin(), p.end());
    work(0);

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T --){
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

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
12
0

result:

wrong answer 2nd numbers differ - expected: '24', found: '12'