QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#733813#9576. Ordainer of Inexorable Judgmentlqh2024WA 0ms3920kbC++203.2kb2024-11-10 21:18:342024-11-10 21:18:34

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-10 21:18:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3920kb
  • [2024-11-10 21:18:34]
  • 提交

answer

#include <bits/stdc++.h>
#include <quadmath.h>
using namespace std;
#define int long long
#define double long double
struct point {
    double x, y;
};

signed main() {
    cin.tie(0) -> sync_with_stdio(0);

    int n;
    double x0, y0, d, t;
    cin >> n >> x0 >> y0 >> d >> t;

    vector<point> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
    }

    double mx = 0, mi = 1e9;
    double PI = acos((double)(-1));
    auto get = [&](double k, double fen, point a) -> double {
        double theta = atan(k / fen);
        // cout << "atan " << theta << "\n";
        if (theta < 0) theta = PI - theta;
        // cout << "atan " << theta << "\n";
        if (theta * 2 < PI && a.x < 0) {
            theta += PI;
        } 
        if (theta * 2 > PI && a.x > 0) {
            theta += PI;
        }
        // if (theta * 2 < PI && a.x < 0) {
        //     theta += PI;
        // }  
        // if (theta * 2 > -PI && a.x < 0) {
        //     theta += PI;
        // }
        // cout << "atan " << theta << "\n";
        return theta;
    };

    // auto sqrt = [&](double x) -> double {
    //     double l = 0, r = x;
    //     for (int i = 0; i < 200; i++) {
    //         double mid = (l + r) / 2;
    //         if (mid * mid > x) r = mid;
    //         else l = mid;
    //     }
    //     return l;
    // };

    for (int i = 1; i <= n; i++) {
        auto [x, y] = a[i];
        if (abs(abs(x) - d) < 1e-9) {
            mx = max(mx, max(PI / 2 + (a[i].y < 0 ? PI : 0), get((y * y - d * d), (2 * x * y), a[i])));
            mi = min(mi, min(PI / 2 + (a[i].y < 0 ? PI : 0), get((y * y - d * d), (2 * x * y), a[i])));
        } else {
            double delta = 4 * x * x * y * y - 4 * (d * d - x * x) * (d * d - y * y);
            double k1 = (-2 * x * y + sqrt(delta));
            double k2 = (-2 * x * y - sqrt(delta));
            mx = max({mx, get(k1, (d * d - x * x) * 2, a[i]), get(k2, (d * d - x * x) * 2, a[i])});
            mi = min({mi, get(k1, (d * d - x * x) * 2, a[i]), get(k2, (d * d - x * x) * 2, a[i])});
            // cout << "? " << k1 / 2 / (d * d - x * x) << " " << k2 / 2 / (d * d - x * x) << "\n";
        }
        // cout << i << " " << mx << " " << mi << "\n";
    }

    auto get_ans = [&](double t) -> double {
        double cnt = 0, res = 0;
        cnt = floor(t / (2 * PI));
        // t -= cnt * 2 * PI;
        // int L = 0, R = 1e5;
        // while (L <= R) {
        //     int mid = (L + R) / 2;
        //     if (mid * 2 * PI <= t) {
        //         cnt = mid;
        //         L = mid + 1;
        //     } else {
        //         R = mid - 1;
        //     }
        // }
        // cout << "cnt " << cnt << "\n";
        t -= cnt * 2 * PI;
        if (mx - mi > PI) {
            res += cnt * (2 * PI - mx + mi);
            res += min(mi, t);
        } else {
            res += cnt * (mx - mi);
            res += max<double>(0, min(mx, t) - mi);
        }

        return res;
    };
    
    cout << fixed << setprecision(12) << get_ans(get(y0, x0, {x0, y0}) + t) - get_ans(get(y0, x0, {x0, y0})) << "\n";
    // cout << get_ans(get(y0, x0, {x0, y0})) << "\n";
    // cout << mx << " " << mi << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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
Wrong Answer
time: 0ms
memory: 3900kb

input:

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

output:

2499.922354094078

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '2499.9223541', error = '0.0001273'