QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#162179#7110. Kuririn MIRACLEucup-team1198#WA 386ms160032kbC++202.1kb2023-09-03 05:53:502023-09-03 05:53:51

Judging History

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

  • [2023-09-03 05:53:51]
  • 评测
  • 测评结果:WA
  • 用时:386ms
  • 内存:160032kb
  • [2023-09-03 05:53:50]
  • 提交

answer

#include <bits/stdc++.h>

#pragma GCC optimize("fast-math")

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()

const ld pi = atan2l(1, 0) * 2;
const int T = 10000000;


ld get_dphi(ld phi, ld u, ld r) {
    ld sinp = sinl(phi);
    return (- u * sinp + sqrtl(u * u * (sinp * sinp + 3))) / (2 * r);
}

ld tphi[T + 2];

void precalc() {
    ld cur_t = 0;
    for (int i = 0; i < T; ++i) {
        ld phi = pi * i / T;
    
        ld dphi = get_dphi(phi, 1, 1);  // at further point better
        cur_t += pi / T / dphi;
        tphi[i + 1] = cur_t;
    }
}

ld get(ld phi, ld v, ld r) {
    ld prop = phi / pi * T;
    int i = floor(prop);

    return r / v * (tphi[i] * (1 - (prop - i)) + tphi[i + 1] * (prop - i));
}

double rush(ld phi, ld r, ld v, ld d, ld t) {
    d -= 2 * r + t * v;

    ld x = - 2 * r * cosl(phi);
    ld y = 2 * r * sinl(phi);

    ld x1 = d - x;
    ld y1 = y;

    ld l = sqrtl(x1 * x1 + y1 * y1);
    ld fac = 2 * v / l;

    x1 *= fac;
    y1 *= fac;

    x1 -= v;

    if (x1 * x > y * y1 - 1e-7) {
        // cerr << l << '\n';
        return l / (2 * v);
    } else {
        return -1;
    }
}

void solve() {
    ld u, r, d;
    
    u = 2.0;
    r = 3;
    d = 30;

    cin >> u >> r >> d;

    if (get(pi, u, r) * u <= d - 4 * r) {
        ld lp = pi / 2;
        ld rp = pi;

        for (int i = 0; i < 200; ++i) {
            ld mp = (lp + rp) / 2;

            ld t = get(mp, u, r);
            if (rush(mp, r, u, d, t) >= 0) {
                rp = mp;
            } else {
                lp = mp;
            }
        }

        ld t = get(rp, u, r);
        cout << t + rush(rp, r, u, d, t) << '\n';

    } else {
        cout << d / u << '\n';        
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    precalc();


    // for (int i = 0; i < T; ++i) {
    //     presin[i] = sinl(pi * i / T);
    //     precos[i] = cosl(pi * i / T);
    //     pre3sin[i] = presin[i] * presin[i] + 3;
    // }

    cout << fixed << setprecision(15);

    int t = 1000;
    cin >> t;
    while (t--) solve();


    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 378ms
memory: 159936kb

input:

1
2.00 3 30.0

output:

8.310579873394436

result:

ok found '8.3105799', expected '8.3105799', error '0.0000000'

Test #2:

score: 0
Accepted
time: 371ms
memory: 160032kb

input:

100
8.66 6.05 71.59
8.44 8.67 82.55
4.23 9.68 24.74
6.63 9.95 7.45
1.2 7.27 97.55
2.08 2.94 31.61
8.48 5.56 20.16
7.35 5.55 52.48
1.35 8.15 51.23
3.88 9.02 72.37
7.03 1.97 57.03
1.78 4.44 93.44
5.5 6.11 52.94
1.09 9.64 69.01
1.01 3.54 16.78
1.63 4.55 44.06
5.82 5.51 5.92
5.62 2.93 76.01
4.75 4.43 73...

output:

4.457837084359021
5.488360779887392
5.848699763593381
1.123680241327300
43.266479694873765
8.305490069047340
2.377358490566038
4.015485950275980
37.948148148148148
18.652061855670103
4.155123625209847
27.178962846204111
9.625454545454545
63.311926605504587
16.613861386138614
15.093994367268540
1.017...

result:

ok 100 numbers

Test #3:

score: -100
Wrong Answer
time: 386ms
memory: 159956kb

input:

1000
7.52 6.68 80.67
5.34 6.82 45.75
3.57 6.35 22.35
9.55 3.65 31.38
9.37 5.73 40.42
1.83 8.38 82.97
4.86 6.13 9.45
3.88 5.34 84.19
6.49 4.15 85.24
6.51 7.23 42.97
3.0 5.98 57.53
9.35 2.76 69.07
6.76 9.16 91.24
2.98 9.89 49.2
9.16 3.85 66.14
1.84 3.03 37.43
8.01 5.04 50.98
4.05 9.86 4.76
5.4 5.49 60...

output:

5.770882599665938
8.567415730337079
6.260504201680672
3.285863874345550
4.313767342582711
25.176483995409997
1.944444444444444
11.406299530881981
6.807191164496170
6.600614439324117
10.727712497440197
3.800197825581363
7.484484248878131
16.510067114093960
3.775696985643974
10.915710977080107
3.51752...

result:

wrong answer 240th numbers differ - expected: '34.0952090', found: '31.9725525', error = '0.0622567'