QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#1181#722267#9576. Ordainer of Inexorable JudgmentLogSingleDogucup-team3519Success!2024-11-14 21:58:152024-11-14 21:58:16

详细

Extra Test:

Wrong Answer
time: 0ms
memory: 3864kb

input:

3 -3 4 1 4
3 -1
5 -5
2 5

output:

0.000000000000

result:

wrong answer 1st numbers differ - expected: '0.8584073', found: '0.0000000', error = '0.8584073'

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722267#9576. Ordainer of Inexorable Judgmentucup-team3519#WA 1ms3968kbC++172.0kb2024-11-07 18:23:322024-11-14 21:59:07

answer

#include <bits/stdc++.h>

using real = long double;
using i64 = int64_t;

i64 sqr(i64 x) {
    return x * x;
}

const real PI = std::acos(static_cast<real>(-1));
const real EPS = 1e-8;

real angle(real x, real y) {
    return std::atan2(y, x);
}
real reduce(real x) {
    while (x >= PI * 2) x -= PI * 2;
    while (x < 0) x += PI * 2;
    return x;
}
real inter(real l, real r, real u, real v) {
    if (r < u || l > v) return 0;
    return std::min(r, v) - std::max(l, u);
}

struct Point {
    int x, y;
};

int main() {
    int n, x0, y0, d;
    real t;
    std::cin >> n >> x0 >> y0 >> d >> t;

    std::vector<Point> p(n);
    for (auto &[x, y] : p) std::cin >> x >> y;

    // for (int i = 0; i < n; ++i) {
    //     auto a = p[i], b = p[(i + 1) % n];
    //     i64 up = sqr(a.x * b.y - a.y * b.x), down = sqr(a.x - b.x) + sqr(a.y - b.y);
    //     // up/down <= d*d
    //     if (up <= down * d * d) {
    //         std::cout << t << '\n';
    //         return 0;
    //     }
    // }

    std::vector<real> v;
    for (int i = 0; i < n; ++i) {
        auto [x, y] = p[i];
        real theta = angle(std::sqrt(real(x * x + y * y - d * d)), d);
        real base = angle(x, y);
        v.push_back(reduce(base - theta));
        v.push_back(reduce(base + theta));
    }
    std::sort(v.begin(), v.end());

    real S = 0, T = 0;
    int cnt = 0;
    for (int i = 0; i < v.size(); ++i) {
        real s = v[(i + 1) % v.size()], t = v[i];
        real range = reduce(t - s);
        if (range <= PI + EPS) {
            S = s, T = t;
            ++cnt;
        }
    }

    real B = angle(x0, y0);
    S = reduce(S - B);
    T = reduce(T - B);

    real C = reduce(T - S);
    real ans = 0;

    while (t >= PI * 2) {
        t -= PI * 2;
        ans += C;
    }

    if (S <= T) {
        ans += inter(0, t, S, T);
    } else {
        ans += inter(0, t, 0, T);
        ans += inter(0, t, S, PI * 2);
    }

    std::cout << std::fixed << std::setprecision(12);
    std::cout << ans << '\n';
}