이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include <bits/stdc++.h>
#define uwu return 0;
using namespace std;
map <pair<int, int>, long long> mp;
long long dis(int a, int b){
if(a == b)
return 0;
if(a > b)
swap(a, b);
if(mp.count({a, b}))
return mp[{a, b}];
return mp[{a, b}] = getDistance(a, b);
}
int hubDistance(int N, int sub) {
int diam_u, diam_v;
long long mx = 0;
for(int i = 1; i < N; i++){
if(dis(0, i) > mx){
mx = dis(0, i);
diam_u = i;
}
}
mx = 0;
for(int i = 0; i < N; i++){
if(dis(diam_u, i) > mx){
mx = dis(diam_u, i);
diam_v = i;
}
}
long long diam = dis(diam_u, diam_v), R;
R = diam;
for(int i = 0; i < N; i++){
long long a = dis(diam_u, i), b = dis(diam_v, i), delta;
delta = (a + b - diam) / 2;
R = min(R, max(a - delta, b - delta));
}
return R;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:43:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
43 | return R;
| ^
towns.cpp:19:28: warning: unused parameter 'sub' [-Wunused-parameter]
19 | int hubDistance(int N, int sub) {
| ~~~~^~~
towns.cpp:36:22: warning: 'diam_u' may be used uninitialized in this function [-Wmaybe-uninitialized]
36 | long long diam = dis(diam_u, diam_v), R;
| ~~~^~~~~~~~~~~~~~~~
towns.cpp:36:22: warning: 'diam_v' 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... |