이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
int hubDistance(int N, int sub) {
pair<int, int> mx={0, 0};
int l=0, r, mn=INT_MAX;
vector<int> dl(N), dr(N);
for (int i=1; i<N;i ++) dl[i]=getDistance(0, i), mx=max(mx, {dl[i], i});
r=mx.second;
dr[l]=dl[r];
for (int i=0; i<N;i ++) if (i!=l&&i!=r) dr[i]=getDistance(r, i);
int dist=dl[r];
map<int, int> mp;
mp[0]=mp[dl[r]]=0;
for (int i=0; i<N; i++)
{
if (i==l||i==r) continue;
int x=dl[i], y=dr[i], h=(x+dist-y)/2, dh=(x+y-dist)/2;
if (mp.find(h)==mp.end()) mp[h]=dh;
else mp[h]=max(mp[h], dh);
}
for (auto [x, a]:mp)
{
int mx=a;
for (auto [y, b]:mp) mx=max(mx, abs(x-y)+b);
mn=min(mn, mx);
}
return mn;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:26:7: warning: declaration of 'mx' shadows a previous local [-Wshadow]
26 | int mx=a;
| ^~
towns.cpp:7:17: note: shadowed declaration is here
7 | pair<int, int> mx={0, 0};
| ^~
towns.cpp:6:28: warning: unused parameter 'sub' [-Wunused-parameter]
6 | 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... |