Submission #990956

#TimeUsernameProblemLanguageResultExecution timeMemory
990956alex_2008Overtaking (IOI23_overtaking)C++17
Compilation error
0 ms0 KiB
#include "overtaking.h"#include <iostream>#include <vector>#include <algorithm>#include <cmath>#include <map>using namespace std;typedef long long ll;vector<vector<pair<ll, ll>>> dp;vector<vector<ll>> esim;vector<ll> t, w, s;ll n, x, l, m;bool cmp(pair<ll, ll> x, pair<ll, ll> y) { if (x.first != y.first) return x.first < y.first; if (w[x.second] != w[y.second]) return w[x.second] < w[y.second]; return x.second < y.second;}void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S) { t.clear(); w.clear(); s.clear(); esim.clear(); dp.clear(); m = M; l = L; x = X; n = 0; for (auto& it : S) { s.push_back(it); } for (ll i = 0; i < N; i++) { if (W[i] > x) { t.push_back(T[i]); w.push_back(W[i]); n++; } } dp.resize(m); esim.resize(m); for (ll i = 0; i < n; i++) { dp[0].push_back({ t[i], i }); } sort(dp[0].begin(), dp[0].end(), cmp); for (ll j = 1; j < m; j++) { ll cur_mx = 0; for (auto& it : dp[j - 1]) { cur_mx = max(cur_mx, it.first + w[it.second] * 1ll * (s[j] - s[j - 1])); dp[j].push_back({ cur_mx, it.second }); } sort(dp[j].begin(), dp[j].end(), cmp); map<ll, ll> mp; for (auto& it : dp[j]) { mp[it.second] = it.first; } cur_mx = 0; for (auto& it : dp[j - 1]) { cur_mx = max(cur_mx, mp[it.second]); esim[j].push_back(cur_mx); } }}ll arrival_time(ll Y) { ll cur_ind = 0; for (auto& it : t) { if (it < Y) cur_ind++; } if (cur_ind == 0) { return l * 1ll * x + Y; } ll time = Y; for (ll i = 1; i < m; i++) { time = max(time + (s[i] - s[i - 1]) * 1ll * x, esim[i][cur_ind - 1]); while (cur_ind > 0 && dp[i][cur_ind - 1].first >= time) { cur_ind--; } if (cur_ind == 0) { return (l - s[i]) * 1ll * x + time; } } return time;}/*int main() { int L, N, X, M, Q; cin >> L >> N >> X >> M >> Q; vector <ll> T(N); vector <int> W(N), S(M); for (auto &it : T) { cin >> it; } for (auto& it : W) { cin >> it; } for (auto& it : S) { cin >> it; } init(L, N, T, W, X, M, S); while (Q--) { ll k; cin >> k; cout << arrival_time(k) << "\n"; }}*/

Compilation message (stderr)

overtaking.cpp:1:24: warning: extra tokens at end of #include directive
    1 | #include "overtaking.h"#include <iostream>#include <vector>#include <algorithm>#include <cmath>#include <map>using namespace std;typedef long long ll;vector<vector<pair<ll, ll>>> dp;vector<vector<ll>> esim;vector<ll> t, w, s;ll n, x, l, m;bool cmp(pair<ll, ll> x, pair<ll, ll> y) {    if (x.first != y.first) return x.first < y.first;    if (w[x.second] != w[y.second]) return w[x.second] < w[y.second];    return x.second < y.second;}void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S) {    t.clear();    w.clear();    s.clear();    esim.clear();    dp.clear();    m = M;    l = L;    x = X;    n = 0;    for (auto& it : S) {        s.push_back(it);    }    for (ll i = 0; i < N; i++) {        if (W[i] > x) {            t.push_back(T[i]);            w.push_back(W[i]);            n++;        }    }    dp.resize(m);    esim.resize(m);    for (ll i = 0; i < n; i++) {        dp[0].push_back({ t[i], i });    }    sort(dp[0].begin(), dp[0].end(), cmp);    for (ll j = 1; j < m; j++) {        ll cur_mx = 0;        for (auto& it : dp[j - 1]) {            cur_mx = max(cur_mx, it.first + w[it.second] * 1ll * (s[j] - s[j - 1]));            dp[j].push_back({ cur_mx, it.second });        }        sort(dp[j].begin(), dp[j].end(), cmp);        map<ll, ll> mp;        for (auto& it : dp[j]) {            mp[it.second] = it.first;        }        cur_mx = 0;        for (auto& it : dp[j - 1]) {            cur_mx = max(cur_mx, mp[it.second]);            esim[j].push_back(cur_mx);        }    }}ll arrival_time(ll Y) {    ll cur_ind = 0;    for (auto& it : t) {        if (it < Y) cur_ind++;    }    if (cur_ind == 0) {        return l * 1ll * x + Y;    }    ll time = Y;    for (ll i = 1; i < m; i++) {        time = max(time + (s[i] - s[i - 1]) * 1ll * x, esim[i][cur_ind - 1]);        while (cur_ind > 0 && dp[i][cur_ind - 1].first >= time) {            cur_ind--;        }        if (cur_ind == 0) {            return (l - s[i]) * 1ll * x + time;        }    }    return time;}/*int main() {    int L, N, X, M, Q;    cin >> L >> N >> X >> M >> Q;    vector <ll> T(N);    vector <int> W(N), S(M);    for (auto &it : T) {        cin >> it;    }    for (auto& it : W) {        cin >> it;    }    for (auto& it : S) {        cin >> it;    }    init(L, N, T, W, X, M, S);    while (Q--) {        ll k;        cin >> k;        cout << arrival_time(k) << "\n";    }}*/
      |                        ^
/usr/bin/ld: /tmp/ccQlhwzc.o: in function `main':
grader.cpp:(.text.startup+0x43e): undefined reference to `init(int, int, std::vector<long long, std::allocator<long long> >, std::vector<int, std::allocator<int> >, int, int, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x48c): undefined reference to `arrival_time(long long)'
collect2: error: ld returned 1 exit status