이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
#define pary(a...) danb(#a, a)
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
template <typename ...T> void qqbx(const char *s, T ...a) {
int cnt = sizeof...(T);
((std::cerr << "\e[1;32m(" << s << ") = ("), ..., (std::cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename T> void danb(const char *s, T L, T R) {
std::cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
std::cerr << (f++ ? ", " : "") << *L;
std::cerr << " ]\e[0m\n";
}
#else
#define debug(...) ((void)0)
#define pary(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
using namespace std;
map<pair<int,int>,int> asked;
int ask(int a, int b) {
if (a == b) return 0;
if (a > b) swap(a, b);
if (asked.count({ a, b })) return asked[{ a, b }];
return asked[{ a, b }] = getDistance(a, b);
}
int hubDistance(int N, int sub) {
assert (1 <= sub && sub <= 6);
int A = 0, B = 0;
for (int i = 1; i < N; i++) {
if (ask(0, i) > ask(0, A)) {
A = i;
}
}
for (int i = 0; i < N; i++) {
if (ask(A, i) > ask(A, B)) {
B = i;
}
}
debug(A, B);
int R = ask(A, B);
for (int i = 0; i < N; i++) {
int AB = ask(A, B);
int AI = ask(A, i);
int BI = ask(B, i);
int AC = (AB + AI - BI) / 2;
int BC = (AB + BI - AI) / 2;
R = min(R, max(AC, BC));
}
debug(R);
return R;
}
# | 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... |