QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#615991#8022. Walkergates_orzWA 0ms3800kbC++202.0kb2024-10-05 21:16:532024-10-05 21:16:53

Judging History

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

  • [2024-10-05 21:16:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3800kb
  • [2024-10-05 21:16:53]
  • 提交

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,tot;

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


    tmp=v2*x-(n-p2);
    if(v2*x>=(n-p2)*2.0) {
        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: 0
Wrong Answer
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
1220.0979929167

result:

wrong answer 2nd numbers differ - expected: '3827.8370014', found: '1220.0979929', error = '0.6812565'