QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#615982#8022. Walkergates_orzWA 0ms3816kbC++201.9kb2024-10-05 21:14:072024-10-05 21:14:10

Judging History

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

  • [2024-10-05 21:14:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2024-10-05 21:14:07]
  • 提交

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;
    }

    double tmp=v1*x-p1;
    tmp=max(tmp,p1);
    double tot=max(n-p2,n-p2+2.0*(p2-(tmp)));
    if(v2*x>=tot)return true;

    /*tmp=v2*x-(n-p2);
    tmp=min(tmp,p2);
    tot=max(p1,p1+2.0*(tmp-p1));
    if(v1*x>=tot)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;
    }

    //cerr<<"res="<<res<<endl;
    //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: 3800kb

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

result:

ok 2 numbers

Test #2:

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

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: 3672kb

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: -100
Wrong Answer
time: 0ms
memory: 3804kb

input:

1
10.0 8.0 0.1 9.0 10

output:

0.3000000004

result:

wrong answer 1st numbers differ - expected: '1.1000000', found: '0.3000000', error = '0.7272727'