Submission #615533

#TimeUsernameProblemLanguageResultExecution timeMemory
615533ApiramTowns (IOI15_towns)C++14
25 / 100
25 ms468 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; int hubDistance(int N, int sub) { int root = 0; vector<int>dist(N); for (int i = 0;i<N;++i){ if (i == root)dist[i] = 0; else dist[i] = getDistance(i,root); } for (int i = 0;i<N;++i){ if (dist[i] > dist[root]){ root = i; } } for (int i = 0;i<N;++i){ if (i == root)dist[i] = 0; else dist[i] = getDistance(i,root); } int root2 = root; for (int i = 0;i<N;++i){ if (dist[i] > dist[root2])root2 = i; } int answer = dist[root2]; vector<int>dist2(N); for (int i = 0;i<N;++i){ if (i == root2){ dist2[i] = 0; } else{ dist2[i] = getDistance(root2,i); } } for (int i = 0;i<N;++i){ int x = (dist[i] + dist2[i] - dist[root2])/2; answer = min(answer,max(dist[i] - x,dist2[i] - x)); } return -answer; }

Compilation message (stderr)

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