QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606227#9434. Italian CuisineshiftWA 0ms3728kbC++202.5kb2024-10-02 23:32:132024-10-02 23:32:14

Judging History

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

  • [2024-10-02 23:32:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3728kb
  • [2024-10-02 23:32:13]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;

using T = i64;

struct Point {
    T x;
    T y;
    Point(T x_ = 0, T y_ = 0) : x(x_), y(y_) {}
    
    operator Point() {
        return Point(x, y);
    }
    Point &operator+=(Point p) & {
        x += p.x;
        y += p.y;
        return *this;
    }
    Point &operator-=(Point p) & {
        x -= p.x;
        y -= p.y;
        return *this;
    }
    Point &operator*=(T v) & {
        x *= v;
        y *= v;
        return *this;
    }
    Point operator-() const {
        return Point(-x, -y);
    }
    friend Point operator+(Point a, Point b) {
        return a += b;
    }
    friend Point operator-(Point a, Point b) {
        return a -= b;
    }
    friend Point operator*(Point a, T b) {
        return a *= b;
    }
    friend Point operator*(T a, Point b) {
        return b *= a;
    }
    friend bool operator==(Point a, Point b) {
        return a.x == b.x && a.y == b.y;
    }
    friend std::istream &operator>>(std::istream &is, Point &p) {
        return is >> p.x >> p.y;
    }
    friend std::ostream &operator<<(std::ostream &os, Point p) {
        return os << "(" << p.x << ", " << p.y << ")";
    }
};

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

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

long double Point_to_Line(Point A, Point B, Point O) {
    auto v1 = B - A, v2 = O - A;
    return std::fabs(cross(v1, v2) / sqrtl(dot(v1, v1)));
}

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

    i64 r;
    Point o;
    std::cin >> o >> r;

    std::vector<Point> h(n);
    for(int i = 0; i < n; i ++ ) {
        std::cin >> h[i];
    }

    auto check = [&](int i, int j) -> bool {
        return Point_to_Line(h[i], h[j], o) >= r and cross(h[j] - h[i], o - h[i]) >= 0;
    };
    
    auto S = [&](int i, int j, int k) -> i64 {
        return std::abs(cross(h[i] - h[j], h[j] - h[k]));
    };

    i64 ans = 0, cur = 0;
    int next = 1;
    for(int i = 0; i < n; i ++ ) {
        while(check(i, (next + 1) % n)) {
            cur += S(i, next, (next + 1) % n);
            next += 1;
            next %= n;
        }
        ans = std::max(ans, cur);
        cur -= S(i, (i + 1) % n, next);
    }
    std::cout << ans << '\n';
}

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

详细

Test #1:

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

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

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'