제출 #529277

#제출 시각아이디문제언어결과실행 시간메모리
529277Cyanmond도시들 (IOI15_towns)C++17
25 / 100
19 ms948 KiB
// clangformat off #include "towns.h" #include <bits/stdc++.h> template <typename T> bool setmax(T &v, const T a) { if (v < a) { v = a; return true; } else { return false; } } template <typename T> bool setmin(T &v, const T a) { if (v > a) { v = a; return true; } else { return false; } } constexpr int max_d = 1000010; int hubDistance(int N, int sub) { if (sub == 1 or sub == 2) { std::vector<int> dist; auto find_maxdist = [&](const int v, std::vector<int> &d) { int max = 0, pos = 0; for (int i = 0; i < N; ++i) { d[i] = getDistance(v, i); if (setmax(max, d[i])) { pos = i; } } return std::make_pair(pos, max); }; std::vector<int> memo(N); const auto [p1, v1] = find_maxdist(0, memo); const auto [p2, diameter] = find_maxdist(p1, memo); int res = max_d; for (int i = 0; i < N; ++i) { if (i == p1 or i == p2) continue; const int d1 = memo[i], d2 = getDistance(p2, i); const int r = ((d1 + d2) - diameter) / 2; setmin(res, std::max(d1 - r, d2 - r)); } return res; } else { return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...