QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#576797#8022. Walkernice333WA 0ms3960kbC++202.1kb2024-09-19 22:30:152024-09-19 22:30:15

Judging History

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

  • [2024-09-19 22:30:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3960kb
  • [2024-09-19 22:30:15]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long

using namespace std;

void solve() {
    std::vector<double> ans;

    double n, p1, v1, p2, v2;
    std::cin >> n >> p1 >> v1 >> p2 >> v2;

    if(p1 > p2) {
        std::swap(p1, p2);
        std::swap(v1, v2);
    }

    double len_L1 = p1, len_R1 = n - p1;
    double len_L2 = p2, len_R2 = n - p2;
    double len_3 = p2 - p1;
    ans.emplace_back((n + std::min(len_L1, len_R1) ) / v1);
    ans.emplace_back((n + std::min(len_L2, len_R2) ) / v2);
    ans.emplace_back(std::max(len_R1 / v1, len_L2 / v2));
//    ans.emplace_back(std::max(len_L1 / v1, (n - len_L1 + len_R2) / v2));
//    ans.emplace_back(std::max((n - len_R2 + len_L1) / v1, len_R2 / v2));
//    ans.emplace_back(std::max(len_L1 / v1, (n - len_L1 + len_3) / v2));
//    ans.emplace_back(std::max((n - len_R2 + len_3) / v1, len_R2 / v2));
    double z = (v1 * len_R2 + 2. * len_3 * v1 - v2 * len_L1) / (2. * (v1 + v2));
    if(z >= 0. || z <= len_3) {
        ans.emplace_back((len_L1 + 2. * z) / v1);
    }
//    z=len_3;
//    ans.emplace_back((len_L1 + 2. * z) / v1);
//    z=0;
//    ans.emplace_back((len_L1 + 2. * z) / v1);
    z = (2. * len_R2 * v1 + len_3 * v1 - 2. * len_L1 * v2) / (v1 + v2);
    if(z >= 0. || z <= len_3) {
        ans.emplace_back((2. * len_L1 + z) / v1);
    }
//    z=len_3;
//    ans.emplace_back((2. * len_L1 + z) / v1);
//    z=0;
//    ans.emplace_back((2. * len_L1 + z) / v1);

//    z = (len_R2 * v1 + 2. * len_3 * v1 - 2. * len_L1 * v2) / (2. * v1 + v2);
//    if(z >= 0. || z <= len_3) {
//        ans.emplace_back((2. * len_L1 + z) / v1);
//    }
//
//    z = (2. * len_R2 * v1 + len_3 * v1 - len_L1 * v2) / (v1 + 2. * v2);
//    if(z >= 0. || z <= len_3) {
//        ans.emplace_back((len_L1 + 2. * z) / v1);
//    }

    double res = ans[0];
    for(auto &i : ans) res = std::min(res, i);
    cout<<fixed<<setprecision(7)<<res<<endl;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    std::cin >> t;
    for(int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.0000000
3827.8370014

result:

ok 2 numbers

Test #2:

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

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.1000000

result:

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

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3928kb

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.0891089

result:

wrong answer 1st numbers differ - expected: '1.2000000', found: '1.0891089', error = '0.0924092'