제출 #1132865

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

vector<ll> start; // start time of each bus
vector<int> speed;//bus speed
vector<int> stops;
int len; // size of road
int n, m; // number of buses and stations
int xsp; // reserve travel time
vector<tuple<ll, ll, bool>> currTimes;
vector<vector<pair<ll, ll>>> ranges;
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S) {
    len = L;
    n = N;
    start = T;
    speed = W;
    xsp = X;
    m = M;
    stops = S;

    for (int i = 0; i < n; i++) {
        currTimes.push_back({start[i], speed[i], false});
    }
    for (int i = 0; i < m-1; i++) {
        ranges.push_back({});
        sort(currTimes.begin(), currTimes.end());
        vector<tuple<ll, ll, bool>> nxt;
        ll maxTime = -1;
        ll dis = stops[i+1] - stops[i];

        for (auto [currTime, sp, special]: currTimes) {
            ll nxtTime = currTime + sp * dis;
            if (currTime < maxTime) nxtTime = max(nxtTime, maxTime);
            maxTime = max(maxTime, nxtTime);
            nxt.push_back({nxtTime, sp, special});
            ranges.back().push_back({currTime, nxtTime});
        }
        sort(ranges.back().begin(), ranges.back().end());
        ll mx = ranges.back()[0].second;
        for (int i = 1; i < ranges.back().size(); i++) {
            mx = max(mx, ranges.back()[i].second);
            ranges.back()[i].second = mx;
        }
        currTimes = nxt;
    }
}

ll arrival_time(ll st) {
    ll ans = st;
    for (int i = 0; i < m-1; i++) {
        int len = ranges[i].size();
        ll dis = stops[i+1] - stops[i];
        ll nxt = ans + dis * xsp;
        int lo = 0, hi = len-1;
        int idx = -1;
        while (lo <= hi) {
            int mid = (lo + hi) / 2;
            if (ranges[i][mid].first < ans) {
                idx = mid;
                lo = mid+1;
            }
            else hi = mid-1;
        }
        if (idx == -1) {
            ans = nxt;
            continue;
        }
        nxt = max(nxt, ranges[i][idx].second);
        ans = nxt;
    }
    return ans;
}
/*
int main() {
    init(6, 4, {20, 10, 40, 0}, {5, 20, 20, 30}, 10, 4, {0, 1, 3, 6});
    cout << arrival_time(0) << '\n';
    cout << arrival_time(50) << "\n";

}*/

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

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:26:9: error: reference to 'ranges' is ambiguous
   26 |         ranges.push_back({});
      |         ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:37:13: error: reference to 'ranges' is ambiguous
   37 |             ranges.back().push_back({currTime, nxtTime});
      |             ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:39:14: error: reference to 'ranges' is ambiguous
   39 |         sort(ranges.back().begin(), ranges.back().end());
      |              ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:39:37: error: reference to 'ranges' is ambiguous
   39 |         sort(ranges.back().begin(), ranges.back().end());
      |                                     ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:40:17: error: reference to 'ranges' is ambiguous
   40 |         ll mx = ranges.back()[0].second;
      |                 ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:41:29: error: reference to 'ranges' is ambiguous
   41 |         for (int i = 1; i < ranges.back().size(); i++) {
      |                             ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:42:26: error: reference to 'ranges' is ambiguous
   42 |             mx = max(mx, ranges.back()[i].second);
      |                          ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:43:13: error: reference to 'ranges' is ambiguous
   43 |             ranges.back()[i].second = mx;
      |             ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:52:19: error: reference to 'ranges' is ambiguous
   52 |         int len = ranges[i].size();
      |                   ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:59:17: error: reference to 'ranges' is ambiguous
   59 |             if (ranges[i][mid].first < ans) {
      |                 ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~
overtaking.cpp:69:24: error: reference to 'ranges' is ambiguous
   69 |         nxt = max(nxt, ranges[i][idx].second);
      |                        ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from overtaking.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
overtaking.cpp:12:30: note:                 'std::vector<std::vector<std::pair<long long int, long long int> > > ranges'
   12 | vector<vector<pair<ll, ll>>> ranges;
      |                              ^~~~~~