이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "towns.h"
using namespace std;
#define ii pair<int, int>
#define mp make_pair
#define inf 1e9;
map<ii, int> cached;
int getD(int a, int b) {
if (a == b) return 0;
if (a > b) swap(a, b);
if (cached.count(mp(a, b))) return cached[mp(a, b)];
return cached[mp(a, b)] = getDistance(a, b);
}
int hubDistance(int N, int sub) {
cached.clear();
int u, v;
int maxDist = -1;
for (int i = 0; i < N; i++) {
if (getD(0, i) > maxDist) {
maxDist = getD(0, i);
u = i;
}
}
maxDist = -1;
for (int i = 0; i < N; i++) {
if (getD(u, i) > maxDist) {
maxDist = getD(u, i);
v = i;
}
}
int opt = inf;
for (int i = 0; i < N; i++) {
int distFromHubToU = (getD(u, i) + getD(u, 0) - getD(i, 0))/2;
int distFromHubToV = getD(u, v) - distFromHubToU;
opt = min(opt, max(distFromHubToU, distFromHubToV));
}
return opt;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:18:28: warning: unused parameter 'sub' [-Wunused-parameter]
18 | int hubDistance(int N, int sub) {
| ~~~~^~~
towns.cpp:42:34: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
42 | int distFromHubToV = getD(u, v) - distFromHubToU;
| ~~~~^~~~~~
towns.cpp:42:34: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
# | 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... |