Submission #294443

#TimeUsernameProblemLanguageResultExecution timeMemory
294443b00n0rpTowns (IOI15_towns)C++17
26 / 100
25 ms1408 KiB
#include "towns.h" #include<bits/stdc++.h> using namespace std; #define REP(i,n) for(int i = 0; i < n; i ++) #define FOR(i,a,b) for(int i = a; i < b; i ++) #define vi vector<int> #define pb push_back #define F first #define S second int d0[1005],dA[1005]; int n,A,B; int dist[1005][1005]; int getDistanc(int i,int j){ return dist[i][j]; } int hubDistance(int N, int sub){ n = N; REP(i,n){ dist[i][i] = 0; FOR(j,i+1,n){ dist[i][j] = getDistance(i,j); dist[j][i] = dist[i][j]; } } A = B = 0; d0[0] = 0; FOR(i,1,n){ d0[i] = getDistanc(0,i); if(d0[i] > d0[A]) A = i; } dA[0] = d0[A]; dA[A] = 0; FOR(i,1,n){ if(i == A) continue; dA[i] = getDistanc(A,i); if(dA[i] > dA[B]) B = i; } int R = 1000000000; map<int,int> gg; // dist from A from path A-0 REP(i,n){ int lol = (dA[0]+dA[i]-d0[i])/2; gg[lol]++; R = min(R,max(dA[B]-lol,lol)); } int cur = 0; int hub = -1; for(auto x:gg){ if(cur > n/2) break; if(max(dA[B]-x.F,x.F) != R){ cur += x.S; continue; } int p1 = x.S,p2 = n-cur-x.S; cur += p1; if(p2 > n/2) continue; if(p1 <= n/2) return R; hub = x.F; } if(hub == -1) return -R; vi elig; REP(i,n){ if((dA[0]+dA[i]-d0[i])/2 == hub) elig.pb(i); } REP(i,(int)elig.size()){ int cnt = 0; for(auto x:elig) cnt += (getDistanc(elig[i],x) != (dA[x]+dA[elig[i]]-2*hub)); if(cnt > n/2) return -R; } return R; } // 8 and 15 getting -ve instead of +ve

Compilation message (stderr)

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