QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623548 | #8022. Walker | Yurily | WA | 0ms | 4016kb | C++20 | 1.3kb | 2024-10-09 13:00:17 | 2024-10-09 13:00:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long double eps=1e-8;
long double p1,v1,p2,v2,n;
bool check(long double x){
long double s1=v1*x,s2=v2*x;
bool ans=0;
ans=ans||(s1+eps>p1+n)||(s1+eps>2*n-p1)
||(s2+eps>p2+n)||(s2+eps>2*n-p2);
//ll
if(s1+eps>p1){
if(s1-eps<2*p1){
ans=ans||(s2+eps>p2-p1+n-p1);
}
else{
long double t=min(s1-2*p1,p2-p1);
ans=ans||(s2+eps>p2-p1-t+n-p1-t);
}
}
//rr
if(s2+eps>n-p2){
if(s2-eps<2*(n-p2)){
ans=ans||(s1+eps>p2-p1+p2);
}
else{
long double t=min(s2-2*(n-p2),p2-p1);
ans=ans||(s1+eps>p2-p1-t+p2-t);
}
}
//rl
ans=ans||(s1+eps>n-p1&&s2+eps>p2);
long double t=(p2-p1)/(v2+v1);
ans=ans||(s1+eps>v1*t*2+p1&&s2+eps>v2*t*2+n-p2);
//lr
if(s1+eps>p1&&s2+eps>n-p2){
if(s1+eps>2*p1){
long double t=min(s1-2*p1,p2-p1);
ans=ans||(s2+eps>n-p2+n-p1-t);
}
else{
ans=ans||(s2+eps>n-p2+n-p1);
}
}
return ans;
}
void solve(){
cin>>n>>p1>>v1>>p2>>v2;
if(p1>p2){
swap(p1,p2);
swap(v1,v2);
}
long double l=0,r=2e7,ans;
while(r-l>eps){
long double mid=(l+r)/2;
// cout<<mid<<endl;
if(check(mid)){
r=mid;
ans=mid;
}
else
l=mid;
}
printf("%.7Lf\n",ans);
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4016kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5000999.9999950 3827.8370014
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 4016kb
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: 0
Accepted
time: 0ms
memory: 3844kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.2000000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.1000000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.3000000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.2000000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
59.9999999
result:
ok found '59.9999999', expected '60.0000000', error '0.0000000'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3764kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
59.9999999
result:
wrong answer 1st numbers differ - expected: '57.5000000', found: '59.9999999', error = '0.0434783'