Submission #1018719

#TimeUsernameProblemLanguageResultExecution timeMemory
1018719parsadox2Towns (IOI15_towns)C++17
35 / 100
11 ms1112 KiB
#include "towns.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; const int N = 1e2 + 20; int n , dis[N][N] , r[N] , L[N] , R[N]; bool Solve(int D) { int lef = 0 , rig = 0 , mid = 0; for(int x = 0 ; x < n ; x++) { if(L[x] < D) lef++; else if(L[x] > D) rig++; else mid++; } //cout << D << " : " << lef << " " << mid << " " << rig << endl; return (lef <= n / 2 && rig <= n/2 && mid <= n / 2); } int hubDistance(int nn , int sub) { n = nn; pair <int , int> D = make_pair(0 , 1); for(int i = 1 ; i < n ; i++) { dis[0][i] = dis[i][0] = getDistance(0 , i); if(dis[0][i] > dis[D.F][D.S]) D = make_pair(0 , i); } for(int i = 0 ; i < n ; i++) if(i != D.S) { dis[i][D.S] = dis[D.S][i] = getDistance(i , D.S); if(dis[i][D.S] > dis[D.F][D.S]) D = make_pair(i , D.S); } int ans = dis[D.F][D.S]; for(int x = 0 ; x < n ; x++) { dis[x][D.F] = dis[D.F][x] = getDistance(x , D.F); r[x] = (dis[x][D.F] + dis[x][D.S] - dis[D.F][D.S]) / 2; L[x] = dis[x][D.F] - r[x]; R[x] = dis[x][D.S] - r[x]; //cout << x << " : " << L[x] << " " << R[x] << endl; ans = min(ans , max(L[x] , R[x])); } ans = -ans; for(int x = 0 ; x < n ; x++) if(L[x] == abs(ans) || R[x] == abs(ans)) if(Solve(L[x])) ans = abs(ans); return ans; }

Compilation message (stderr)

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