제출 #1223371

#제출 시각아이디문제언어결과실행 시간메모리
1223371HappyCapybara도시들 (IOI15_towns)C++20
25 / 100
10 ms328 KiB
#include "towns.h" #include<bits/stdc++.h> using namespace std; map<pair<int,int>,int> res; int getDist(int a, int b){ if (a == b) return 0; if (a > b) swap(a, b); if (res.find({a, b}) == res.end()) res[{a, b}] = getDistance(a, b); return res[{a, b}]; } int hubDistance(int N, int sub){ res.clear(); int bsf = 0, f1, f2; for (int i=1; i<N; i++){ int d = getDist(0, i); if (d > bsf){ bsf = d; f1 = i; } } bsf = 0; for (int i=0; i<N; i++){ if (i == f1) continue; int d = getDist(f1, i); if (d > bsf){ bsf = d; f2 = i; } } int diam = getDist(f1, f2); int j0 = (getDist(f1, 0)+getDist(f1, f2)-getDist(f2, 0))/2; map<int,vector<int>> m; int R = pow(10, 9); for (int i=0; i<N; i++){ int jp = (getDist(f1, 0)+getDist(f1, i)-getDist(0, i))/2; jp = min(j0, jp); R = min(R, max(jp, diam-jp)); } return R; }
#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...