제출 #1038987

#제출 시각아이디문제언어결과실행 시간메모리
1038987Zicrus추월 (IOI23_overtaking)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "overtaking.h"
using namespace std;

typedef unsigned long long ll;

vector<vector<ll>> tCur, tNxt;
vector<ll> s;
ll x, m;

void init(int l, int n, vector<ll> t, vector<int> w, int x1, int m1, vector<int> s1) {
    s = vector<ll>(s1.size());
    for (int i = 0; i < s1.size(); i++) s[i] = s1[i];
    m = m1;
    x = x1;
    tCur = vector<vector<ll>>(m-1);
    tNxt = vector<vector<ll>>(m-1);
    vector<pair<ll, ll>> busses(n);
    for (int i = 0; i < n; i++) {
        busses[i] = {t[i], w[i]};
    }
    sort(busses.begin(), busses.end());

    for (int t = 0; t < m-1; t++) {
        for (int i = 0; i < n; i++) {
            ll curTime = busses[i].first;
            if (t > 0) {
                ll idealNxt = curTime + busses[i].second * (s[t] - s[t-1]);
                auto iter = lower_bound(tCur[t-1].begin(), tCur[t-1].end(), curTime);
                ll id = iter - tCur[t-1].begin();
                ll mxNxt = id > 0 ? tNxt[t-1][id-1] : 0;
                busses[i].first = curTime = max(idealNxt, mxNxt);
            }
            ll idealNxt = curTime + busses[i].second * (s[t+1] - s[t]);
            auto iter = lower_bound(tCur[t].begin(), tCur[t].end(), curTime);
            ll id = iter - tCur[t].begin();
            ll mxNxt = id > 0 ? tNxt[t][id-1] : 0;
            ll nxt = max(idealNxt, mxNxt);
            if (nxt > mxNxt) {
                if (id < tCur[t].size() && curTime == tCur[t][id]) {
                    tNxt[t][id] = nxt;
                }
                else {
                    auto iter2 = upper_bound(tNxt[t].begin(), tNxt[t].end(), nxt);
                    tCur[t].erase(iter, tCur[t].begin() + (iter2 - tNxt[t].begin()));
                    tNxt[t].erase(tNxt[t].begin() + id, iter2);

                    tCur[t].insert(iter, curTime);
                    tNxt[t].insert(tNxt[t].begin() + id, nxt);
                }
            }
        }
    }
}

ll arrival_time(ll y) {
    for (int t = 0; t < m-1; t++) {
        ll idealNxt = y + x * (s[t+1] - s[t]);
        ll id = lower_bound(tCur[t].begin(), tCur[t].end(), y) - tCur[t].begin();
        ll mxNxt = id > 0 ? tNxt[t][id-1] : 0;
        y = max(idealNxt, mxNxt);
    }
    return y;
}

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

overtaking.cpp: In function 'void init(int, int, std::vector<long long unsigned int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < s1.size(); i++) s[i] = s1[i];
      |                     ~~^~~~~~~~~~~
overtaking.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   24 |     for (int t = 0; t < m-1; t++) {
      |                     ~~^~~~~
overtaking.cpp: In function 'll arrival_time(ll)':
overtaking.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   57 |     for (int t = 0; t < m-1; t++) {
      |                     ~~^~~~~
/usr/bin/ld: /tmp/ccCxfaeu.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