제출 #119440

#제출 시각아이디문제언어결과실행 시간메모리
119440PeppaPig도시들 (IOI15_towns)C++14
25 / 100
24 ms620 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; const int N = 205; int hubDistance(int n, int sub) { vector<vector<int> > d(N, vector<int>(N, 0)); auto get_dist = [&](int a, int b) { if(a == b) return 0; else if(d[a][b]) return d[a][b]; else return d[a][b] = d[b][a] = getDistance(a, b); }; int a, b; for(int i = 0, mx = -1; i < n; i++) if(get_dist(0, i) > mx) a = i, mx = get_dist(0, i); for(int i = 0, mx = -1; i < n; i++) if(get_dist(a, i) > mx) b = i, mx = get_dist(a, i); int lim = (get_dist(a, b) + get_dist(a, 0) - get_dist(b, 0)) / 2; vector<int> hub; int root1 = -1, root2 = -1, ans = INT_MAX; for(int i = 0; i < n; i++) { int pos = (get_dist(a, i) + get_dist(a, 0) - get_dist(i, 0)) / 2; hub.emplace_back(pos); ans = min(ans, max(pos, get_dist(a, b) - pos)); if(get_dist(a, i) == get_dist(a, b)) { if(root1 == -1) root1 = pos; else if(pos != root1) root2 = pos; } } sort(hub.begin(), hub.end()); hub.resize(unique(hub.begin(), hub.end()) - hub.begin()); auto chk = [&](int root) { int l = 0, r = 0; for(int i = 0; i < n; i++) { int pos = (get_dist(a, i) + get_dist(a, 0) - get_dist(i, 0)) / 2; if(pos < root) ++l; if(pos > root) ++r; } return (l <= n / 2 && r <= n / 2); }; if(!chk(root1) && (root2 == -1 || !chk(root2))) return -ans; auto chk2 = [&](int root) { int cnt = 0; for(int i = 0; i < n; i++) { int pos = (get_dist(a, i) + get_dist(a, 0) - get_dist(i, 0)) / 2; if(pos == root) ++cnt; } return cnt <= n / 2; }; if(!chk2(root1) && (root2 == -1 || !chk2(root2))) return -ans; return ans; auto same = [&](int root, int a, int b) { }; auto majority_vote = [&](int root) { }; }

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

towns.cpp: In lambda function:
towns.cpp:56:40: warning: declaration of 'b' shadows a previous local [-Wshadow]
  auto same = [&](int root, int a, int b) {
                                        ^
towns.cpp:16:9: note: shadowed declaration is here
  int a, b;
         ^
towns.cpp:56:40: warning: declaration of 'a' shadows a previous local [-Wshadow]
  auto same = [&](int root, int a, int b) {
                                        ^
towns.cpp:16:6: note: shadowed declaration is here
  int a, b;
      ^
towns.cpp:56:22: warning: unused parameter 'root' [-Wunused-parameter]
  auto same = [&](int root, int a, int b) {
                      ^~~~
towns.cpp:56:32: warning: unused parameter 'a' [-Wunused-parameter]
  auto same = [&](int root, int a, int b) {
                                ^
towns.cpp:56:39: warning: unused parameter 'b' [-Wunused-parameter]
  auto same = [&](int root, int a, int b) {
                                       ^
towns.cpp: In lambda function:
towns.cpp:59:31: warning: unused parameter 'root' [-Wunused-parameter]
  auto majority_vote = [&](int root) {
                               ^~~~
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:20:6: warning: unused variable 'lim' [-Wunused-variable]
  int lim = (get_dist(a, b) + get_dist(a, 0) - get_dist(b, 0)) / 2;
      ^~~
towns.cpp:56:7: warning: variable 'same' set but not used [-Wunused-but-set-variable]
  auto same = [&](int root, int a, int b) {
       ^~~~
towns.cpp:59:7: warning: variable 'majority_vote' set but not used [-Wunused-but-set-variable]
  auto majority_vote = [&](int root) {
       ^~~~~~~~~~~~~
towns.cpp:8:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int n, int sub) {
                            ^~~
towns.cpp:11:3: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(a == b) return 0;
   ^~
towns.cpp:11:3: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(a == b) 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...