QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#722254#9576. Ordainer of Inexorable Judgmentucup-team3519#RE 0ms3948kbC++172.1kb2024-11-07 18:20:072024-11-07 18:20:08

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-11-14 21:58:28]
  • hack成功,自动添加数据
  • (/hack/1181)
  • [2024-11-07 18:20:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3948kb
  • [2024-11-07 18:20: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;
        }
    }
    assert(cnt <= 1);

    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';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1.000000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.570796326795

result:

ok found '1.5707963', expected '1.5707963', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.707752257475

result:

ok found '2500.7077523', expected '2500.7077523', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

0.384241300290

result:

ok found '0.3842413', expected '0.3842413', error '0.0000000'

Test #5:

score: -100
Runtime Error

input:

3 -10000 -10000 10000 10000
-10000 -9999
-10000 -10000
-9999 -10000

output:


result: