이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, N) for (int i=0; i<(N); i++)
#define pb push_back
#define _1 first
#define _2 second
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define INF 1145141919
using namespace std;
typedef pair<int, int> P;
int N;
int memo[111][111];
int Rank[111];
int dist(int a, int b) {
if (memo[a][b] != -1) return memo[a][b];
return memo[a][b] = getDistance(a, b);
}
int saien(int x) {
P mp = P(-1, -1);
rep(t, N) mp = max(mp, P(dist(x, t), t));
return mp._2;
}
int hubDistance(int NN, int sub) {
N=NN;
rep(i, N) rep(j, N) memo[i][j] = -1;
rep(i, N) memo[i][i] = 0;
int u = saien(0);
int v = saien(u);
vector<int> pos;
int L = dist(u, v);
pos.pb(0);
pos.pb(L);
rep(x, N) if (x != u && x != v) {
Rank[x] = dist(u, x)+dist(v, x)-dist(u, v);
pos.pb(dist(u, x)-Rank[x]);
}
sort(all(pos)); uniq(pos);
P mp = P(INF, -1);
for (int x : pos) mp = min(mp, P(max(x, L-x), x));
int R = mp._1;
return R;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:28:29: warning: unused parameter 'sub' [-Wunused-parameter]
int hubDistance(int NN, 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... |