QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#615829 | #8022. Walker | gates_orz | WA | 0ms | 3928kb | C++20 | 1.6kb | 2024-10-05 20:28:42 | 2024-10-05 20:28:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
#define double long double
#define int LL
double n, m;
const int N = 3e5 + 10;
const int M = N * 2;
const double eps=1e-9;
double p1,v1,p2,v2;
bool check(double x) {
double t1=p1/v1;
double t2=(n-p2)/v2;
t1=x-t1;
t2=x-t2;
if(t1>=eps&&t2>=eps) {
if(v1*t1+v2*t2>=(p2-p1)*2.0)return true;
}
t1=p1*2.0/v1;
t2=(n-p2)*2.0/v2;
t1=x-t1;
t2=x-t2;
if(t1>=eps&&t2>=eps) {
if(v1*t1+v2*t2>=p2-p1)return true;
}
return false;
}
void solve() {
cin>>n>>p1>>v1>>p2>>v2;
if(p1>=p2) {
swap(p1,p2);
swap(v1,v2);
}
double res=0;
double l=0,r=2e7;
//for(int i=1;i<=100;i++)
while(r-l>eps) {
double mid=(l+r)/2;
if(check(mid))r=mid,res=mid;
else l=mid;
}
//p1走全程
if((p1+n)/v1<=res) {
res=(p1+n)/v1;
}
if((n+n-p1)/v1<=res) {
res=(n+n-p1)/v1;
}
//p2走全程
if((n+n-p2)/v2<=res) {
res=(n+n-p2)/v2;
}
if((n+p2)/v2<=res) {
res=(n+p2)/v2;
}
if((p1/v1)*v2-(n-p2)>=(n-p1)) {
if(res>=(p1/v1))res=p1/v1;
}
if(((n-p2)/v2)*v1-p1>=p2) {
if(res>=(n-p2)/v2)res=(n-p2)/v2;
}
if(res>=max(p2/v2,(n-p1)/v1)) {
res=max(p2/v2,(n-p1)/v1);
}
cout<<fixed<<setprecision(10)<<res<<"\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--)solve();
return 0;
}
/*
1
2 1
a/b/c
a/b/d
e
*/
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.0000000004 3827.8370013756
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3872kb
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: 3872kb
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: 3840kb
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: 3824kb
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: 3880kb
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: 3928kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
57.5000000003
result:
ok found '57.5000000', expected '57.5000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
1 10.0 1.0 1.0 8.0 1.0
output:
6.5000000005
result:
ok found '6.5000000', expected '6.5000000', error '0.0000000'
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 3872kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.6666666670
result:
wrong answer 1st numbers differ - expected: '4.6000000', found: '4.6666667', error = '0.0144928'