Submission #494642

#TimeUsernameProblemLanguageResultExecution timeMemory
494642thecodingwizardTowns (IOI15_towns)C++11
25 / 100
16 ms852 KiB
#include <bits/stdc++.h> #include "towns.h" using namespace std; #define ii pair<int, int> #define mp make_pair map<ii, int> cached; int getD(int a, int b) { if (a > b) swap(a, b); if (cached.count(mp(a, b))) return cached[mp(a, b)]; return cached[mp(a, b)] = getDistance(a, b); } int hubDistance(int N, int sub) { cached.clear(); int maxDist = -1, maxDistNode = -1; for (int i = 1; i < N; i++) { int d = getD(0, i); if (d > maxDist) { maxDist = d; maxDistNode = i; } } maxDist = -1; int maxDistNode2 = -1; for (int i = 0; i < N; i++) { int d = getD(maxDistNode, i); if (d > maxDist) { maxDist = d; maxDistNode2 = i; } } int opt = 1e9; for (int i = 0; i < N; i++) { int distTo0 = getD(maxDistNode2, i); int distTo1 = getD(maxDistNode, i); int dist0 = (maxDist + distTo0 - distTo1)/2; int dist1 = (maxDist + distTo1 - distTo0)/2; opt = min(opt, max(dist0, dist1)); } return opt; }

Compilation message (stderr)

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