Submission #616043

#TimeUsernameProblemLanguageResultExecution timeMemory
616043ApiramTowns (IOI15_towns)C++14
0 / 100
15 ms352 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; int hubDistance(int N, int sub) { int root = 0; vector<int>dist(N),dist2(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)dist2[i] = 0; else if (i == 0)dist2[i] = dist[root]; else dist2[i] = getDistance(i,root); } int root2 = root; for (int i = 0;i<N;++i){ if (dist2[i] > dist2[root2])root2 = i; } int answer = dist2[root2]; vector<int>dist3(N); for (int i = 0;i<N;++i){ if (i == root2){ dist3[i] = 0; } else if (i == 0)dist3[i] = dist[root2]; else if (i == root)dist3[i] = dist2[root2]; else{ dist3[i] = dist[i] + dist[root2] - 2 * (dist[root] + dist[i] - dist2[i])/2; } } for (int i = 0;i<N;++i){ int x = (dist2[i] + dist3[i] - dist2[root2])/2; answer = min(answer,max(dist2[i] - x,dist3[i] - x)); } /*for (int i = 0;i<N;++i){ int x = (dist[i] + dist2[i] - dist[root2])/2; if (answer == max(dist[i] - x,dist2[i] - x)){ int sub1 = 0,sub2 = 0,sub3 = 0,sub4 = 0; for (int j = 0;j<N;++j){ if (dist[j] <= dist[i] - x){ sub1++; } else if (dist2[j]<=dist2[i] - x){ sub2++; } else if (getDistance(i,j) <=x)sub3++; else sub4++; if (sub4 > N / 2 + 2)break; if (sub3 > N / 2)break; } while (sub4 > N/2){ --sub4; ++sub3; } if (max({sub1,sub2,sub3,sub4}) <=N/2){ return answer; } break; } } */ 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...