QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#725292 | #8022. Walker | nnk | WA | 0ms | 3872kb | C++20 | 2.1kb | 2024-11-08 17:00:22 | 2024-11-08 17:00:22 |
Judging History
answer
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<math.h>
#include<map>
#include<bitset>
#include<numeric>
#include <cstring>
#include<array>
#include <string>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
//#define endl "\n"
#define mod 1000000007ll
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr)
#define syy return
const double pi = acos(-1.0);
using ll = long long;
using pii = pair<int, int>;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vint>;
using vpo = vector<pii>;
using tup = tuple<int, int, int>;
using vbl = vector<bool>;
constexpr int N = 100000, M = 2000006;//开足够的空间 注意无向图的双向边边数*2
constexpr ll inf = 1e16;
long double eps = 1e-7;
set<int> all;
void solve()
{
double p1, v1, p2, v2, ans, n;
cin >> n >> p1 >> v1 >> p2 >> v2;
if (p1 > p2) {
swap(p1, p2);
swap(v1, v2);
}
//一个人走完全程
ans = (min(p1, n - p1) + n) / v1;
ans = min(ans, (min(p2, n - p2) + n) / v2);
//相反方向走
ans = min(ans, (n + p1 + (n - p2)) / (v1 + v2));
double tt = min(max((p2 + p1) / v1, (n - p2) / v2), max((n - p1 + n - p2) / v2, p1 / v1)), x, x2;
ans = min(ans, tt);
//相对方向走
ans = min(ans, (n + p2 - p1) / (v1 + v2));
//相同方向走
x = (2 * n * v1 + p1 * v2 - p2 * v1) / (v1 + 2 * v2);
if (x >= p1 && x <= p2)
ans = min(ans, (2 * x - p1) / v1);
// else ans = min(ans, max((p2 + p2 - p1) / v1, (n - p2) / v2));
x2 = (n * v1 + p2 * v1 - p1 * v2) / (2 * v1 + v2);
if (x2 >= p1 && x2 <= p2)
ans = min(ans, (n + p2 - 2 * x2) / v2);
//else ans = min(ans, max((p2 - p1 + n - p1) / v2, p1 / v1));
cout << setiosflags(ios::fixed) << setprecision(10) << ans << endl;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3872kb
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: 3812kb
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: -100
Wrong Answer
time: 0ms
memory: 3868kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.0891089109
result:
wrong answer 1st numbers differ - expected: '1.2000000', found: '1.0891089', error = '0.0924092'