이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "towns.h"
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 110;
int d[N][N];
int dS[N], dT[N];
int hubDistance(int n, int sub) {
int S = 0;
for (int i = 0; i < n; ++i) dS[i] = getDistance(0, i);
for (int i = 0; i < n; ++i)
if (dS[i] > dS[S]) S = i;
for (int i = 0; i < n; ++i) dS[i] = getDistance(S, i);
int T = 0;
for (int i = 0; i < n; ++i)
if (dS[i] > dS[T]) T = i;
for (int i = 0; i < n; ++i) dT[i] = getDistance(T, i);
int R = 1e9;
int h = 0;
for (int i = 0; i < n; ++i) {
int cur = (dS[T] + dS[i] - dT[i]) / 2;
if (max(cur, dS[T] - cur) < R) {
R = max(cur, dS[T] - cur);
h = cur;
}
}
if (sub < 3) return R;
if (sub == 4) {
int up = 0, down = 0, mid = 0;
for (int i = 0; i < n; ++i) {
int cur = (dS[T] + dS[i] - dT[i]) / 2;
if (cur < h) ++up;
if (cur > h) ++down;
if (cur == h) ++mid;
}
if (max({up, down, mid}) <= n / 2) return R;
return - R;
}
return R;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
2 | #pragma GCC optimization ("O3")
|
towns.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
3 | #pragma GCC optimization ("unroll-loops")
|
# | 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... |