이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
inline int max(int X, int Y) { return (X > Y ? X : Y); }
int to_0[110], A, to_A[110], B;
int R = 1000000, hubs[2], hub_cnt = 0;
int hubDistance(int N, int sub) {
for (int i = 1, best_A = 0; i < N; i++) {
to_0[i] = getDistance(0, i);
if (to_0[i] > best_A) A = i, best_A = to_0[i];
}
to_A[0] = to_0[A];
for (int i = 0, best_B = 0; i < N; i++) {
if (i == A) continue;
to_A[i] = getDistance(A, i);
if (to_A[i] > best_B) B = i, best_B = to_A[i];
}
for (int i = 0; i < N; i++) {
if (!i || i == A) continue;
int A_to_potential_hub = (to_A[i] + to_A[0] - to_0[i]) / 2;
int potential_R = max(A_to_potential_hub, to_A[B] - A_to_potential_hub);
if (potential_R < R) R = potential_R, hub_cnt = 0;
if (potential_R == R) hubs[hub_cnt++] = i;
}
return R;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:8:28: warning: unused parameter 'sub' [-Wunused-parameter]
int hubDistance(int N, int sub) {
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |