이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "towns.h"
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const int MAXN = 0;
int getDistance(int i, int j);
int hubDistance(int n, int sub){
vector<int> ds (n,0), db(n,0), da(n,-1);
int a, b;
int maxi = -1;
for(int i = 1; i < n; i++){
ds[i] = getDistance(0,i);
if(ds[i] > maxi)
maxi = ds[i], b = i;
}
maxi = -1;
db[0] = ds[b];
for(int i = 1; i < n; i++){
if(i==b)
continue;
db[i] = getDistance(b,i);
if(db[i] > maxi)
maxi = db[i], a = i;
}
da[a] = 0;
da[b] = db[a];
vector<int> dlca(n,0);
for(int i = 0; i < n; i++){
dlca[i] = (db[0] + db[i] - ds[i])>>1;
}
int resp = INF;
for(int i = 0; i < n; i++){
resp = min(resp, max(dlca[i], db[a] - dlca[i]));
}
return resp;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:17:28: warning: unused parameter 'sub' [-Wunused-parameter]
17 | int hubDistance(int n, int sub){
| ~~~~^~~
towns.cpp:29:17: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
29 | db[0] = ds[b];
| ^
towns.cpp:37:9: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
37 | da[a] = 0;
| ^
# | 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... |