제출 #1061224

#제출 시각아이디문제언어결과실행 시간메모리
1061224aykhnOvertaking (IOI23_overtaking)C++17
65 / 100
3543 ms42068 KiB
#include "overtaking.h"
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define mxn (ll)(1e3 + 5)
 
ll n, m, l, x;
vector<ll> w, t, s;
vector<pii> v[mxn];
vector<pii> ran[mxn];
vector<ll> pref[mxn];
 
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S)
{
    n = N, m = M, l = L, x = X;
    for (ll x : W)  w.pb(x); for (ll x : T)  t.pb(x); for (ll x : S)  s.pb(x);
    for (ll i = 0; i < n; i++) v[0].pb({t[i], w[i]});
    for (ll i = 0; i + 1 < m; i++)
    {
        sort(v[i].begin(), v[i].end(), [&](const pii &a, const pii &b)
        {
            if (a.fi == b.fi) return a.se < b.se;
            return a.fi < b.fi;
        });
        for (ll j = 0; j < v[i].size(); j++)
        {
            if (!j || pref[i][j - 1] <= v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se)
            {
                v[i + 1].pb({v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se, v[i][j].se});
                ran[i].pb({v[i][j].fi, v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se});
                pref[i].pb(v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se);
                continue;
            }
            v[i + 1].pb({pref[i][j - 1], v[i][j].se});
            ran[i].pb({v[i][j].fi, pref[i][j - 1]});
            pref[i].pb(pref[i][j - 1]);
        }
    }
}
 
ll arrival_time(ll Y)
{
    ll cur = Y;
    for (ll i = 0; i + 1 < m; i++)
    {
        ll ind = lower_bound(ran[i].begin(), ran[i].end(), mpr(cur, -1000LL)) - ran[i].begin() - 1;
        if (ind < 0 || ind >= ran[i].size() || ran[i][ind].se <= cur + (s[i + 1] - s[i]) * x)
        {
            cur = cur + (s[i + 1] - s[i]) * x;
            continue;
        }
        cur = ran[i][ind].se;
    }
    return cur;
}

컴파일 시 표준 에러 (stderr) 메시지

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:23:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   23 |     for (ll x : W)  w.pb(x); for (ll x : T)  t.pb(x); for (ll x : S)  s.pb(x);
      |     ^~~
overtaking.cpp:23:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   23 |     for (ll x : W)  w.pb(x); for (ll x : T)  t.pb(x); for (ll x : S)  s.pb(x);
      |                              ^~~
overtaking.cpp:32:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for (ll j = 0; j < v[i].size(); j++)
      |                        ~~^~~~~~~~~~~~~
overtaking.cpp: In function 'll arrival_time(ll)':
overtaking.cpp:54:28: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         if (ind < 0 || ind >= ran[i].size() || ran[i][ind].se <= cur + (s[i + 1] - s[i]) * x)
      |                        ~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...