Submission #74160

#TimeUsernameProblemLanguageResultExecution timeMemory
74160funcsrTowns (IOI15_towns)C++17
25 / 100
24 ms3744 KiB
#include "towns.h" #include <iostream> #include <algorithm> #include <vector> #define rep(i, N) for (int i=0; i<(N); i++) #define pb push_back #define _1 first #define _2 second #define all(x) x.begin(), x.end() #define uniq(x) x.erase(unique(all(x)), x.end()) #define INF 1145141919 using namespace std; typedef pair<int, int> P; int N; int memo[111][111]; int Rank[111]; int dist(int a, int b) { if (memo[a][b] != -1) return memo[a][b]; return memo[a][b] = getDistance(a, b); } int saien(int x) { P mp = P(-1, -1); rep(t, N) mp = max(mp, P(dist(x, t), t)); return mp._2; } int hubDistance(int NN, int sub) { N=NN; rep(i, N) rep(j, N) memo[i][j] = -1; rep(i, N) memo[i][i] = 0; int u = saien(0); int v = saien(u); vector<int> pos; int L = dist(u, v); pos.pb(0); pos.pb(L); rep(x, N) if (x != u && x != v) { Rank[x] = (dist(u, x)+dist(v, x)-L)/2; pos.pb(dist(u, x)-Rank[x]); } sort(all(pos)); uniq(pos); P mp = P(INF, -1); //cout<<"L="<<L<<"\n"; //for (int x : pos)cout<<x<<",";cout<<"\n"; for (int x : pos) mp = min(mp, P(max(x, L-x), x)); int R = mp._1; return R; }

Compilation message (stderr)

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