제출 #552735

#제출 시각아이디문제언어결과실행 시간메모리
552735iancu도시들 (IOI15_towns)C++14
25 / 100
20 ms1096 KiB
#include "towns.h" #include <vector> using namespace std; int hubDistance(int N, int sub) { vector<vector<int>> dist(N, vector<int>(N, -1)); auto getDist = [&dist](int a, int b) { if (dist[a][b] == -1) dist[a][b] = dist[b][a] = getDistance(a, b); return dist[a][b]; }; int D1, D2, dist_max = 0; for (int i = 1; i < N; ++i) if (getDist(0, i) > dist_max) { dist_max = getDist(0, i); D1 = i; } dist_max = 0; for (int i = 0; i < N; ++i) if (i != D1 && getDist(D1, i) > dist_max) { dist_max = getDist(D1, i); D2 = i; } int R = getDist(D1, D2); for (int i = 0; i < N; ++i) if (i != D1 && i != D2) { int dist_i = (getDist(D1, i) - getDist(D2, i) + getDist(D1, D2)) / 2; R = min(R, max(dist_i, getDist(D1, D2) - dist_i)); } return R; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:6:32: warning: unused parameter 'sub' [-Wunused-parameter]
    6 |     int hubDistance(int N, int sub) {
      |                            ~~~~^~~
towns.cpp:9:19: warning: 'D1' may be used uninitialized in this function [-Wmaybe-uninitialized]
    9 |         if (dist[a][b] == -1)
      |                   ^
towns.cpp:10:48: warning: 'D2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   10 |           dist[a][b] = dist[b][a] = getDistance(a, b);
      |                                     ~~~~~~~~~~~^~~~~~
#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...