Submission #257054

#TimeUsernameProblemLanguageResultExecution timeMemory
257054eohomegrownappsTowns (IOI15_towns)C++14
25 / 100
23 ms624 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> distv; int n; int dist(int a, int b){ if (a==b){return 0;} if (a>b){ swap(a,b); } if (distv[a][b]!=-1){ return distv[a][b]; } else { return distv[a][b]=getDistance(a,b); } } int hubDistance(int N, int sub) { n=N; distv.assign(n,vector<int>(n,-1)); int adist = -1; int aind = -1; for (int i = 0; i<n; i++){ int ds = dist(0,i); if (adist<ds){ adist=ds; aind=i; } } int bdist = -1; int bind = -1; for (int i = 0; i<n; i++){ int ds = dist(aind,i); if (bdist<ds){ bdist=ds; bind=i; } } //from adist to aind //vector<int> diameter; int hubdist = 1e9; int hubind = -1; for (int i = 0; i<n; i++){ if (i==aind||i==bind){continue;} int distfroma = dist(aind,i)-(dist(aind,i)+dist(bind,i)-dist(aind,bind))/2; int rv = max(distfroma,dist(aind,bind)-distfroma); if (rv<hubdist){ hubdist=rv; hubind=i; } } return -hubdist; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:48:9: warning: variable 'hubind' set but not used [-Wunused-but-set-variable]
     int hubind = -1;
         ^~~~~~
towns.cpp:20: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...