이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int dist[maxn][maxn];
int hubDistance(int N, int sub) {
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++) dist[i][j] = -1;
for (int i = 1; i < N; i++) {
int x = getDistance(0, i);
dist[i][0] = x, dist[0][i] = x;
}
int r1 = 1, r2;
for (int i = 1; i < N; i++)
if (dist[0][r1] < dist[0][i]) r1 = i;
for (int i = 0; i < N; i++) {
int x = getDistance(r1, i);
dist[r1][i] = x, dist[i][r1] = x;
}
r2 = r1;
for (int i = 0; i < N; i++)
if (dist[r1][r2] < dist[r1][i]) {
// cout << dist[r1][r2] << " " << dist[r1][i] << " " << i << "\n";
r2 = i;
}
for (int i = 0; i < N; i++) {
int x = getDistance(i, r2);
dist[i][r2] = x, dist[r2][i] = x;
}
// cerr << r1 << " " << r2 << "\n";
map<int, int> mii;
for (int i = 0; i < N; i++)
if (i != r1 && i != r2) {
int sumall = (dist[i][r1] + dist[r1][r2] + dist[i][r2]) / 2;
int tor1 = sumall - dist[i][r2], toi = sumall - dist[r1][r2],
tor2 = sumall - dist[i][r1];
mii[tor1] = max({mii[tor1], tor1, tor2, toi});
}
int maxi = INT_MAX;
for (auto a : mii) maxi = min(maxi, a.second);
return maxi;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:8:28: warning: unused parameter 'sub' [-Wunused-parameter]
8 | 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... |