Submission #432612

#TimeUsernameProblemLanguageResultExecution timeMemory
432612balbitTowns (IOI15_towns)C++14
25 / 100
25 ms972 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define f first #define s second #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__) template<typename T> void _do( T && x) {cerr<<x<<endl;} template<typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);} #else #define bug(...) #endif // BALBIT #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int )((x).size()) #define pb push_back #define REP(i,n) for (int i = 0; i<n; ++i) #define REP1(i,n) for (int i = 1; i<=n; ++i) #define MX(a,b) a = max(a,b) #define MN(a,b) a = min(a,b) map<pii, int> mp; int getd(int a, int b){ if (a==b) return 0; if (a>b) swap(a,b); if (!mp.count({a,b})) mp[{a,b}] = getDistance(a,b); return mp[{a,b}]; } int hubDistance(int n, int sub) { mp.clear(); int p1=-1, p2=-1; { int far = 0; REP(i,n) { if (i != 0) { if (getd(0,i) > far) { far = getd(0,i); p1 = i; } } } } vector<int> A(n); vector<int> B(n); { int far = 0; REP(i,n) { if (i!=p1) { A[i] = getd(p1, i); if (getd(p1,i) > far) { far = getd(p1,i); p2 = i; } } } } assert(p1 != -1 && p2 != -1); bug(p1, p2); int R = 2000000000; int dia = A[p2]; REP(i,n) { B[i] = getd(p2,i); int hi = (dia + abs(A[i] - B[i])); assert(hi % 2 == 0); MN(R, hi / 2); } bug(dia, R); return R; }

Compilation message (stderr)

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