제출 #588193

#제출 시각아이디문제언어결과실행 시간메모리
588193AlperenT철로 (IOI14_rail)C++17
30 / 100
66 ms512 KiB
#include <bits/stdc++.h> #include "rail.h" using namespace std; void findLocation(int n, int A, int location[], int stype[]){ location[0] = A; stype[0] = 1; A = 0; if(n == 1) return; int distA[n] = {}; int distB[n] = {}; for(int i = 1; i < n; i++){ distA[i] = getDistance(A, i); } int B = min_element(distA + 1, distA + n) - distA; location[B] = location[A] + distA[B]; stype[B] = 2; vector<pair<int, int>> lft, rght; for(int i = 1; i < n; i++){ if(i != B){ distB[i] = getDistance(B, i); if(distA[i] == distA[B] + distB[i]) lft.push_back({distB[i], i}); else rght.push_back({distA[i], i}); } } sort(lft.begin(), lft.end()); if(!lft.empty()){ int C = lft.front().second; location[C] = location[B] - distB[C]; stype[C] = 1; for(int i = 1; i < lft.size(); i++){ int X = lft[i].second; int dist = getDistance(C, X); if(distB[X] == distB[C] + dist){ location[X] = location[C] + dist; stype[X] = 2; } else{ location[X] = location[B] - distB[X]; stype[X] = 1; C = X; } } } sort(rght.begin(), rght.end()); if(!rght.empty()){ int D = rght.front().second; location[D] = location[A] + distA[D]; stype[D] = 2; for(int i = 1; i < rght.size(); i++){ int X = rght[i].second; int dist = getDistance(D, X); if(distA[X] == distA[D] + dist){ location[X] = location[D] - dist; stype[X] = 1; } else{ location[X] = location[A] + distA[X]; stype[X] = 2; D = X; } } } }

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i = 1; i < lft.size(); i++){
      |                  ~~^~~~~~~~~~~~
rail.cpp:70:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |   for(int i = 1; i < rght.size(); i++){
      |                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...