제출 #858867

#제출 시각아이디문제언어결과실행 시간메모리
858867superMOOZ추월 (IOI23_overtaking)C++17
0 / 100
3570 ms2908 KiB
#include "overtaking.h" #include <vector> #include <set> #include <algorithm> using namespace std; int L, N, X, M; vector<long long> T; vector<int> W, S; pair<long long, int> arrival_vec[1005][1005]; // [stop][rank] = {time, id} long long arrival_t[1005][1005]; // [stop][id] vector<pair<long long, long long>> info[1005]; // sorted - [stop][..] = {from time, earliest arrival} void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) { ::L = L; ::N = N; ::T = T; ::W = W; ::X = X; ::M = M; ::S = S; for (int i=0; i<N; ++i) { arrival_vec[0][i] = {T[i], i}; arrival_t[i][0] = T[i]; } sort(arrival_vec[0], arrival_vec[0] + N); for (int stop=1; stop<M; ++stop) { long long earliest_arrival = 0; for (int i=0; i<N; ++i) { int id = arrival_vec[stop-1][i].second; long long arrival = arrival_t[stop-1][id] + 1LL*(S[stop]-S[stop-1])*W[id]; arrival = max(arrival, earliest_arrival); arrival_vec[stop][i] = {arrival, id}; arrival_t[stop][id] = arrival; earliest_arrival = arrival; } sort(arrival_vec[stop], arrival_vec[stop] + N); } // Preprocessing vector<pair<pair<long long, int>, long long>> tmap[1005]; // [stop] = {{{{time, state}, earliest arrival}}, ...} for (int stop=1; stop<M; ++stop) { for (auto p : arrival_vec[stop]) { long long arrival = p.first; int id = p.second; long long prev_from = p.first - 1LL*(S[stop]-S[stop-1])*W[id]; long long prev_to = p.first - 1LL*(S[stop]-S[stop-1])*X; if (prev_from < prev_to) { tmap[stop-1].push_back({{prev_from + 1, 1}, arrival}); tmap[stop-1].push_back({{prev_to, -1}, arrival}); } } } for (int stop=0; stop<M-1; ++stop) { sort(tmap[stop].begin(), tmap[stop].end()); multiset<long long> blockers; for (int i=0; i<tmap[stop].size(); ++i) { const auto& p = tmap[stop][i]; long long time = p.first.first; int state = p.first.second; long long earliest_arrival = p.second; if (state == 1) { blockers.insert(earliest_arrival); } else { blockers.erase(blockers.find(earliest_arrival)); } if (i != tmap[stop].size()-1 && tmap[stop][i].first.first == tmap[stop][i+1].first.first) continue; auto it = blockers.begin(); if (it == blockers.end()) { info[stop].push_back({time, 0}); } else { info[stop].push_back({time, *it}); } } } return; } long long arrival_time(long long Y) { for (int stop=0; stop<M-1; ++stop) { int l=0, r=(int)info[stop].size() - 1; int res = -1; while (l<=r) { int mid = (l+r)/2; if (info[stop][mid].first > Y) r = mid-1; else { res = mid; l = mid+1; } } long long earliest_arrival = 0; if (res != -1) earliest_arrival = info[stop][res].second; Y = max(earliest_arrival, Y + 1LL*(S[stop+1]-S[stop])*X); } return Y; }

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

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:61:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (int i=0; i<tmap[stop].size(); ++i) {
      |                       ~^~~~~~~~~~~~~~~~~~
overtaking.cpp:71:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |             if (i != tmap[stop].size()-1 && tmap[stop][i].first.first == tmap[stop][i+1].first.first) continue;
      |                 ~~^~~~~~~~~~~~~~~~~~~~~~
#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...