QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657482#8022. Walkeryumingsk#WA 14ms3932kbC++202.6kb2024-10-19 14:50:232024-10-19 14:50:23

Judging History

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

  • [2024-10-19 14:50:23]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3932kb
  • [2024-10-19 14:50:23]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;

double abs2(double a) { return a < 0 ? -a : a; }
double max(double a, double b) { return a > b ? a : b; }
double min(double a, double b) { return a < b ? a : b; }
double n, p1, p2, v1, v2, t, minn, p;

void solve()
{
    cin >> n >> p1 >> v1 >> p2 >> v2;
    if (p2 < p1)
    {
        t = p1;
        p1 = p2;
        p2 = t;
        t = v1;
        v1 = v2;
        v2 = t;
    }
    minn = min(min((p1 + n) / v1, (n * 2 - p1) / v1), min((p2 + n) / v2, (n * 2 - p2) / v2));
    p = (p2 * v1 + n * v1 - p1 * v2) / (2 * v1 + v2);
    if (p1 <= p && p <= p2)
    {
        minn = min(minn, max(min((p + p1) / v1, (p * 2 - p1) / v1), min((n + p2 - p * 2) / v2, (n * 2 - p - p2) / v2)));
    }
    p = (p2 * v1 + n * v1 + p1 * v2) / (2 * v1 + 2 * v2);
    if (p1 <= p && p <= p2)
    {
        minn = min(minn, max(min((p + p1) / v1, (p * 2 - p1) / v1), min((n + p2 - p * 2) / v2, (n * 2 - p - p2) / v2)));
    }
    p = (0 - p1 * v2 + 2 * n * v1 - p2 * v1) / (v1 + v2);
    if (p1 <= p && p <= p2)
    {
        minn = min(minn, max(min((p + p1) / v1, (p * 2 - p1) / v1), min((n + p2 - p * 2) / v2, (n * 2 - p - p2) / v2)));
    }
    p = (p1 * v2 + 2 * n * v1 - p2 * v1) / (v1 + 2 * v2);
    if (p1 <= p && p <= p2)
    {
        minn = min(minn, max(min((p + p1) / v1, (p * 2 - p1) / v1), min((n + p2 - p * 2) / v2, (n * 2 - p - p2) / v2)));
    }
    p = p1;
    if (p1 <= p && p <= p2)
    {
        minn = min(minn, max(min((p + p1) / v1, (p * 2 - p1) / v1), min((n + p2 - p * 2) / v2, (n * 2 - p - p2) / v2)));
    }
    p = p2;
    if (p1 <= p && p <= p2)
    {
        minn = min(minn, max(min((p + p1) / v1, (p * 2 - p1) / v1), min((n + p2 - p * 2) / v2, (n * 2 - p - p2) / v2)));
    }
    cout << fixed << setprecision(10) << minn << '\n';
}
int main()
{
    IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
#ifndef ONLINE_JUDGE
    cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
    return 0;
}
// (p*2-p1)/v1==(2*n-p-p2)/v2
// p*(2/v1+1/v2)==(2*n-p2)/v2+p1/v1
// (p+p1)/v1==(p2+n-2*p)/v2
// p*(1/v1+2/v2)==(p2+n)/v2+p1/v1

详细

Test #1:

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

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.0000000000
3827.8370013755

result:

ok 2 numbers

Test #2:

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

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.1000000000

result:

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

Test #3:

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

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.2000000000

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.1000000000

result:

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

Test #5:

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

input:

1
10.0 2.0 0.1 3.0 10

output:

1.3000000000

result:

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

Test #6:

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

input:

1
10.0 9.0 0.1 8.0 10.0

output:

1.2000000000

result:

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

Test #7:

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

input:

1
10.0 4.0 0.1 6.0 0.1

output:

60.0000000000

result:

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

Test #8:

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

input:

1
10.0 4.5 0.1 6.0 0.1

output:

57.5000000000

result:

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

Test #9:

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

input:

1
10.0 1.0 1.0 8.0 1.0

output:

6.5000000000

result:

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

Test #10:

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

input:

1
10.0 3.0 2.0 7.0 1.0

output:

4.6000000000

result:

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

Test #11:

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

input:

1
10.0 6.0 2.0 7.0 1.0

output:

3.6666666667

result:

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

Test #12:

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

input:

1
10.0 1.0 1.0 9.0 1.0

output:

6.0000000000

result:

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

Test #13:

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

input:

1
10000.0 1.0 0.001 1.0 0.001

output:

9999000.0000000000

result:

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

Test #14:

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

input:

1
10.0 5.0 1.0 5.0 1.5

output:

5.0000000000

result:

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

Test #15:

score: -100
Wrong Answer
time: 14ms
memory: 3816kb

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.8370013755
7999.3649921507
12559.3358024691
15415.5444617785
2637.6985195155
9931.0415175376
934.4943011398
4326.9490616622
5754.0328898744
2847.4271570014
10975.3236282195
2902.1791044776
24531.5363636364
6278.1035548686
1030.0000000000
10734.3956442831
1005.0770288858
24249.7467811159
9878.00...

result:

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