Submission #781685

#TimeUsernameProblemLanguageResultExecution timeMemory
781685vjudge1Towns (IOI15_towns)C++17
13 / 100
28 ms872 KiB
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define ft first
#define nd second
#define pb push_back


const int INF = 1e9 + 7;

int hubDistance(int N, int sub) {
	int dist[N][N];
	for (int i = 0; i < N; i++){
		dist[i][i] = 0;
		for (int j = i + 1; j < N; j++){
			dist[i][j] = dist[j][i] = getDistance(i, j);
		}
	}

	int ans = INF;
	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++){
			int d1 = (dist[1][i] - dist[1][j] + dist[i][j]) / 2;
			int d2 = dist[i][j] - d1;
			int curr = max(d1, d2);
			for (int k = 0; k < N; k++){
				int x1 = dist[k][i] - d1, x2 = dist[k][j] - d2;
				curr = max(curr, max(x1, x2));
			}
			//cout<<i<<sp<<j<<sp<<curr<<endl;
			ans = min(ans, curr);
		}
	}
	return ans;
}

Compilation message (stderr)

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