제출 #963481

#제출 시각아이디문제언어결과실행 시간메모리
963481sleepntsheepCity Mapping (NOI18_citymapping)C++17
13 / 100
1 ms856 KiB
#include "citymapping.h" #include <vector> #include <algorithm> #define N 1005 void find_roads(int n, int q, int A[], int B[], int W[]) { if (q != 12000) return; int root = 1, ad = -1; int d[N] = { 0 }, e[N] = { 0 }; for (int i = 2; i <= n; ++i) { d[i] = get_distance(root, i); if (ad == -1 || d[i] < d[ad]) ad = i; } for (int i = 1; i <= n; ++i) e[i] = get_distance(ad, i); std::vector<int> left, right; left.push_back(ad); for (int i = 1; i <= n; ++i) { if (i == ad || i == root) continue; if (e[i] < d[i]) left.push_back(i); else right.push_back(i); } std::sort(left.begin(), left.end(), [&](int i, int j){ return d[i] < d[j] ; }); std::sort(right.begin(), right.end(), [&](int i, int j){ return d[i] < d[j] ; }); for (int pre = root, i = 0; i < left.size(); ++i) { A[i] = pre; B[i] = left[i]; W[i] = d[left[i]] - d[pre]; pre = B[i]; } for (int pre = root, j = 0, i = left.size(); i < n - 1; ++i, ++j) { A[i] = pre; B[i] = right[j]; W[i] = d[right[j]] - d[pre]; pre = B[i]; } return; }

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

citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:37:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int pre = root, i = 0; i < left.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...
#Verdict Execution timeMemoryGrader output
Fetching results...