QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#379488#8022. Walkercomeintocalm#WA 103ms3932kbC++171.9kb2024-04-06 17:38:522024-04-06 17:38:53

Judging History

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

  • [2024-04-06 17:38:53]
  • 评测
  • 测评结果:WA
  • 用时:103ms
  • 内存:3932kb
  • [2024-04-06 17:38:52]
  • 提交

answer

#include <bits/stdc++.h>
#define LL long long
#define db long double
using namespace std;

int T;
constexpr db eps = 1e-15;
db n, p[2], v[2];

bool chk (db t) {
    db l1 = t * v[0], l2 = t * v[1];
    if (l1 - (p[0] + n) > eps || l1 - (2 * n - p[0]) > eps) {
        return true;
    }
    if (l2 - (p[1] + n) > eps || l2 - (2 * n - p[1]) > eps) {
        return true;
    }
    if (l1 - p[0] < eps || l2 - (n - p[1]) < eps) {
        return false;
    }
    db out1 = std::max(l1 - 2 * p[0], (l1 - p[0]) / 2);
    db out2 = std::max(l2 - 2 * (n - p[1]), (l2 - (n - p[1])) / 2);
    if (out1 > 0 && out2 > 0 && out1 + out2 - (p[1] - p[0]) > 0) {
        return true;
    }
    return false;
}

int main() {
    // freopen("in", "r", stdin);
    scanf ("%d", &T);
    while (T--) {
        scanf ("%Lf%Lf%Lf%Lf%Lf", &n, &p[0], &v[0], &p[1], &v[1]);
        if (p[0] > p[1]) swap (p[0], p[1]), swap (v[0], v[1]);
        db L = 0, R = 1e9;
        int cnt = 500;
        while (cnt--) {
            db mid = (L + R) / 2.0;
            if (chk (mid)) R = mid;
            else L = mid;
        }
        printf ("%.18Lf\n", L);
        /*
        db ans = min (calc (0, 0, n), calc (1, 0, n));
        //printf ("%.15Lf\n", ((db) 1000) / ((db)0.001));
        //printf ("%.15Lf\n", ans);
        //return 0;
        //ans = min (ans, max (0, 0, p[1]))
        //cout << n << endl;
        //cout << calc (0, 0, n) << endl;
        db L = p[0], R = p[1];
        int cnt = 300;
        while (cnt--) {
            db fm = (R - L) / ((db) 3.0), m1 = L + fm, m2 = R - fm;
            db a1 = max (calc (0, 0, m1), calc (1, m1, n));
            db a2 = max (calc (0, 0, m2), calc (1, m2, n));
            ans = min (ans, a1);
            ans = min (ans, a2);
            if (a1 < a2) R = m2;
            else L = m1;
        }
        ans = min (ans, max (calc (0, 0, L), calc (1, L, n)));
        printf ("%.15Lf\n", ans);
        */
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3884kb

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.000000000000000000
3827.837001375515818546

result:

ok 2 numbers

Test #2:

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

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.100000000000000100

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #3:

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

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.200000000000000100

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #4:

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

input:

1
10.0 8.0 0.1 9.0 10

output:

1.100000000000000100

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

1
10.0 2.0 0.1 3.0 10

output:

1.300000000000000100

result:

ok found '1.3000000', expected '1.3000000', error '0.0000000'

Test #6:

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

input:

1
10.0 9.0 0.1 8.0 10.0

output:

1.200000000000000100

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #7:

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

input:

1
10.0 4.0 0.1 6.0 0.1

output:

60.000000000000000000

result:

ok found '60.0000000', expected '60.0000000', error '0.0000000'

Test #8:

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

input:

1
10.0 4.5 0.1 6.0 0.1

output:

57.500000000000000000

result:

ok found '57.5000000', expected '57.5000000', error '0.0000000'

Test #9:

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

input:

1
10.0 1.0 1.0 8.0 1.0

output:

6.500000000000000000

result:

ok found '6.5000000', expected '6.5000000', error '0.0000000'

Test #10:

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

input:

1
10.0 3.0 2.0 7.0 1.0

output:

4.600000000000000000

result:

ok found '4.6000000', expected '4.6000000', error '0.0000000'

Test #11:

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

input:

1
10.0 6.0 2.0 7.0 1.0

output:

3.666666666666666667

result:

ok found '3.6666667', expected '3.6666667', error '0.0000000'

Test #12:

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

input:

1
10.0 1.0 1.0 9.0 1.0

output:

6.000000000000000000

result:

ok found '6.0000000', expected '6.0000000', error '0.0000000'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

1
10000.0 1.0 0.001 1.0 0.001

output:

9999000.000000000000909495

result:

ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'

Test #14:

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

input:

1
10.0 5.0 1.0 5.0 1.5

output:

5.000000000000001000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #15:

score: -100
Wrong Answer
time: 103ms
memory: 3812kb

input:

10000
4306.063 4079.874 0.607 1033.423 0.847
8967.336 8026.500 0.398 283.019 0.876
9568.147 4481.616 0.405 800.114 0.684
9867.264 6184.040 0.312 9853.164 0.641
3344.364 730.612 0.539 1305.868 0.947
9336.180 3672.113 0.773 432.686 0.312
1468.243 59.762 0.840 1438.446 0.827
1355.133 1096.314 0.373 109...

output:

3827.837001375515818546
7999.364992150706436647
12559.335802469135805026
15415.544461778471141855
2637.698519515477792785
9931.041517537580529229
934.494301139772045650
4326.949061662198394274
5754.032889874353288828
2847.427157001414428361
10975.323628219484883850
2902.179104477611941704
24531.5363...

result:

wrong answer 4th numbers differ - expected: '15371.5507020', found: '15415.5444618', error = '0.0028620'