QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#48434#3962. 100 meter dashvk1cd314WA 1ms7940kbC++202.3kb2022-09-13 15:57:182022-09-13 15:57:20

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-13 15:57:20]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7940kb
  • [2022-09-13 15:57:18]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N= 3e5;
long double x[N],y[N],t[N];

long double getdist(int i,int j){
    return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    long double lst=0;
    //x[0]=y[0]=t[0]=0;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>t[i];
        //t[i] -= lst;
        lst= t[i];
    }

    //for (int i = 1; i < n; ++i) {
        //cout << i << " = " << getdist(i, i - 1) << '\n';
    //}

    int j=0;
    long double tot= 0,res=2e18;
    for(int i=0;i<n;i++){
        while(j<n && tot-getdist(j,(j+1)%n)+1e-12>100){
            tot-=getdist(j,(j+1)%n);
            j++;
        }

        if(tot+1e-12>100){
            long double t1=t[j + 1],t2=t[i];
            if(i)t2 -= t[i-1];
            t1 -= t[j];
            long double l= getdist(j,(j+1)%n)/t1, r= getdist(i,i - 1)/t2;
            if(l>r){
                long double ext= tot-100.0;
                long double subt=0;
                long double tmp= min(ext,getdist(i-1,i));
               // cout << "imp" << tot << ' ' << ext << " here\n";
                ext -= tmp;
                subt += tmp/r;

                tmp= min(ext,getdist(j,(j+1)%n));
                ext -= tmp;
                subt += tmp/l;
                //cout << "dist\n";
                //cout<<j<<" "<<i<<" "<<t[i] - t[j]<<" "<<subt<<endl;
                res=min(res,t[i]-t[j]-subt);
            }
            else {
                long double ext= tot-100.0;
                long double subt=0;
                long double tmp= min(ext,getdist(j,(j+1)%n));
               // cout << "imp" << tot << ' ' << ext << " here\n";
                ext -= tmp;
                subt += tmp/l;

                tmp= min(ext,getdist(i-1,i));
                ext -= tmp;
                subt += tmp/r;
                // cout<<j<<" "<<i<<" "<<(100.0/(t[i]-t[j]-subt))<<" "<<subt<<endl;
                //cout<<j<<" "<<i<<" "<<t[i] - t[j]<<" "<<subt<<endl;
                res=min(res,t[i]-t[j]-subt);
            }
        }
        tot += getdist(i,(i+1)%n);
    }
	
	cout<<setprecision(8)<<fixed;
    cout<<res<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7940kb

input:

2
50 0 10
140 0 20

output:

2000000000000000000.00000000

result:

wrong answer 1st numbers differ - expected: '12.00000', found: '2000000000000000000.00000', error = '166666666666666656.00000'