제출 #843835

#제출 시각아이디문제언어결과실행 시간메모리
843835ogkostya추월 (IOI23_overtaking)C++17
39 / 100
3527 ms16976 KiB
#include "overtaking.h" #include <algorithm> #include <utility> std::vector<std::vector<std::pair<long long, long long>>> SS(1001, std::vector<std::pair<long long, long long>>()); struct sort1 { inline bool operator() (const std::pair<long long, int>& a, const std::pair<long long, int>& b) { return (a.first < b.first); } }; struct sort2 { inline bool operator() (const std::pair<long long, long long>& a, const std::pair<long long, long long>& b) { if (b.second == a.second) return a.first < b.first; return (b.second < a.second); } }; void sortVecPair(std::vector<long long>& vecA, std::vector<int>& vecB) { std::vector<std::pair<long long, int>> vecC; vecC.reserve(vecA.size()); for (int i = 0; i < vecA.size(); i++) { vecC.push_back(std::make_pair(vecA[i], vecB[i])); } std::sort(vecC.begin(), vecC.end(), sort1()); vecA.clear(); vecB.clear(); vecA.reserve(vecC.size()); vecB.reserve(vecC.size()); for (int i = 0; i < vecC.size(); i++) { vecA.push_back(vecC[i].first); vecB.push_back(vecC[i].second); } } int _M; std::vector<int> _S; int _X; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) { _X = X; _M = M; _S = S; sortVecPair(T, W); for (int i = 0; i < N; i++) { //if (W[i] > X) /// continue; long long a = T[i]; for (int j = 1; j < M; j++) { long long b = a + 1LL * (_S[j] - _S[j - 1]) * W[i]; for (int k = 0; k < SS[j].size(); k++) { if (SS[j][k].first < a && SS[j][k].second > b) b = SS[j][k].second; } SS[j].push_back(std::make_pair(a, b)); a = b; } } for (int j = 1; j < M; j++) { std::sort(SS[j].begin(), SS[j].end(), sort2()); std::vector<std::pair<long long, long long>> sorted; for (int i = 0; i < SS[j].size(); i++) { if (sorted.size() == 0) sorted.push_back(SS[j][i]); else { if (sorted.back().second == SS[j][i].second) { continue; } else { sorted.push_back(SS[j][i]); } } } SS[j] = sorted; } return; } long long arrival_time(long long Y) { long long a = Y; for (int j = 1; j < _M; j++) { long long b = a + 1LL * (_S[j]-_S[j-1]) * _X; for (int k = 0; k < SS[j].size(); k++) { if (SS[j][k].second <= b) break; if (SS[j][k].first < a) b = SS[j][k].second; } a = b; } return a; }

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

overtaking.cpp: In function 'void sortVecPair(std::vector<long long int>&, std::vector<int>&)':
overtaking.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < vecA.size(); i++)
      |                     ~~^~~~~~~~~~~~~
overtaking.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 0; i < vecC.size(); i++)
      |                     ~~^~~~~~~~~~~~~
overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:70:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             for (int k = 0; k < SS[j].size(); k++)
      |                             ~~^~~~~~~~~~~~~~
overtaking.cpp:87:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         for (int i = 0; i < SS[j].size(); i++)
      |                         ~~^~~~~~~~~~~~~~
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:118:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |         for (int k = 0; k < SS[j].size(); k++)
      |                         ~~^~~~~~~~~~~~~~
#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...