제출 #127416

#제출 시각아이디문제언어결과실행 시간메모리
127416kingfran1907도시들 (IOI15_towns)C++14
25 / 100
67 ms4984 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; const int maxn = 120; const int maxm = 1e6+10; const int inf = 0x3f3f3f3f; int qs[maxn][maxn]; int sol[maxm]; vector<int> v; vector<int> li, buk; int query(int a, int b) { if (a > b) swap(a, b); if (qs[a][b] == -1) qs[a][b] = getDistance(a, b); return qs[a][b]; } int a, b; int B; bool subtree(int x, int y) { int xd = (query(a, x) + query(b, x) - query(a, b)) / 2; int yd = (query(a, y) + query(b, y) - query(a, b)) / 2; return xd + yd - query(x, y) > 0; } int hubDistance(int n, int sub) { memset(qs, -1, sizeof qs); memset(sol, inf, sizeof sol); for (int i = 0; i < n; i++) qs[i][i] = 0; a = 0, b = 0; for (int i = 0; i < n; i++) if (query(0, a) < query(0, i)) a = i; for (int i = 0; i < n; i++) if (query(a, b) < query(a, i)) b = i; B = b; b = 0; for (int i = 0; i < n; i++) { int cd = (query(a, i) + query(b, i) - query(a, b)) / 2; int ad = query(a, i) - cd; int bd = query(a, B) - ad; sol[ad] = max({cd, ad, bd}); } int hu = 0; for (int i = 0; i < maxm; i++) if (sol[hu] > sol[i]) hu = i; /** //int lef = 0, rig = 0; v.clear(); for (int i = 0; i < n; i++) v.push_back(i); li.clear(); buk.clear(); li.push_back(v[0]); for (int i = 1; i < n; i++) { if (subtree(v[i], li.back())) buk.push_back(v[i]); else { li.push_back(v[i]); if (!buk.empty()) { li.push_back(buk.back()); buk.pop_back(); } } } int cnt = buk.size(); for (int i = 0; i < li.size(); i++) if (subtree(li[i], li.back())) cnt++, i++; if (cnt > n / 2) return -sol[hu]; else return sol[hu]; **/ return sol[hu]; }

컴파일 시 표준 에러 (stderr) 메시지

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:28:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int n, int sub) {
                            ^~~
#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...