QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558549#3962. 100 meter dashLaVuna47WA 33ms4480kbC++173.0kb2024-09-11 16:43:352024-09-11 16:43:42

Judging History

This is the latest submission verdict.

  • [2024-09-11 16:43:42]
  • Judged
  • Verdict: WA
  • Time: 33ms
  • Memory: 4480kb
  • [2024-09-11 16:43:35]
  • Submitted

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

double my_dist(pdd p1, pdd p2)
{
	return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

struct Point
{
    double x, y;
    double t;
};

double get_ans(const vector<double>& dist, const vector<double>& dt, int n)
{
    int l = 0;
    int r = 0;
    double best_t = 1e47;
    double cur_t = 0;
    double cur_dist = 0;
    while(true)
    {
        while(r < n && cur_dist + dist[r] < 100)
        {
            cur_dist += dist[r];
            cur_t += dt[r];
            ++r;
        }
        if(r == n)
            break;
        assert(cur_dist < 100 && cur_dist + dist[r] >= 100);
        double sp = dist[r]/dt[r];
        best_t = min(cur_t + (100-cur_dist)/sp, best_t);        
        cur_t -= dt[l];
        cur_dist -= dist[l];
        l += 1;
        r = max(l, r);
    }
    return best_t;
}

int solve()
{
    int n;
    if(!(cin >> n))
        return 1;
    vector<double> dist(n,0), dt(n,0);
    pdd pr_pos = {0, 0};
    double pr_time = 0;
    FOR(i, n)
    {
        pdd cur_pos;
        double cur_time;
        cin >> cur_pos.x >> cur_pos.y >> cur_time;
        dist[i] = my_dist(cur_pos, pr_pos);
        dt[i] = cur_time-pr_time;
        pr_pos = cur_pos;
        pr_time = cur_time;
        
    }
    
    double ans = get_ans(dist, dt, n);
    reverse(all(dist));
    reverse(all(dt));
    ans = min(ans, get_ans(dist, dt, n));
    
    cout << fixed << setprecision(8) << ans << '\n';
	return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3848kb

input:

2
50 0 10
140 0 20

output:

12.00000000

result:

ok found '12.00000', expected '12.00000', error '0.00000'

Test #2:

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

input:

6
84.39 0 10
120.89 36.5 14.3
84.39 73 18.4
0 73 28.5
-36.5 36.5 32.7
0 0 36.95

output:

8.13029907

result:

ok found '8.13030', expected '8.13030', error '0.00000'

Test #3:

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

input:

5
20 0 1
50 0 6
30 0 8
-40 0 15
40 0 17

output:

4.00000000

result:

ok found '4.00000', expected '4.00000', error '0.00000'

Test #4:

score: -100
Wrong Answer
time: 33ms
memory: 4480kb

input:

85860
-18.000000 15.000000 28.000000
-58.000000 -69.000000 39.000000
61.000000 26.000000 54.000000
42.000000 52.000000 67.000000
-8.000000 -83.000000 78.000000
-68.000000 29.000000 97.000000
-14.000000 62.000000 114.000000
86.000000 -15.000000 127.000000
0.000000 34.000000 148.000000
-23.000000 54.0...

output:

-18.95312435

result:

wrong answer 1st numbers differ - expected: '4.39445', found: '-18.95312', error = '5.31297'