제출 #1135463

#제출 시각아이디문제언어결과실행 시간메모리
1135463gyg도시들 (IOI15_towns)C++20
0 / 100
11 ms1468 KiB
// Note: 0-indexed, multiple tests #include "towns.h" #include <bits/stdc++.h> using namespace std; #define arr array #define pii pair<int, int> #define fir first #define sec second #define vec vector const int N = 115, INF = 2e9; int n; arr<int, N> dst; arr<int, N> a_dst, b_dst; int fr(int u) { pii mx = {-1, -1}; for (int v = 1; v <= n; v++) dst[v] = getDistance(u - 1, v - 1), mx = max(mx, {dst[v], v}); assert(mx.sec != -1); return mx.sec; } map<int, vec<int>> cmp_mp; vec<pair<int, vec<int>>> cmp; vec<int> in_a, in_b; void intl() { cmp_mp.clear(); cmp.clear(); in_a.clear(), in_b.clear(); } int hubDistance(int _n, int _s) { n = _n; int a = fr(1); int b = fr(a); a_dst = dst; fr(b); b_dst = dst; for (int u = 1; u <= n; u++) if (u != a && u != b) cmp_mp[a_dst[u] - b_dst[u]].push_back(u); for (pair<int, vec<int>> x : cmp_mp) cmp.push_back(x); in_a.resize(cmp.size()), in_b.resize(cmp.size()); pair<int, vec<int>> bst = {INF, {}}; for (int i = 0; i < cmp.size(); i++) { in_a[i] = (cmp[i].fir + a_dst[b]) / 2; in_b[i] = (-cmp[i].fir + a_dst[b]) / 2; int vl = max(in_a[i], in_b[i]); if (vl < bst.fir) bst = {vl, {i}}; else if (vl == bst.fir) bst.sec.push_back(i); } return bst.fir; }
#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...