Submission #104415

# Submission time Handle Problem Language Result Execution time Memory
104415 2019-04-06T17:20:36 Z figter001 Towns (IOI15_towns) C++17
0 / 100
29 ms 1152 KB
#include "towns.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 120;

int n,dis[nax][nax],R;

int query(int a,int b){
	if(dis[a][b] != 0)
		return dis[a][b];
	dis[a][b] = dis[b][a] = getDistance(a,b);
	return dis[a][b];
}

int far(int u){
	int mx = 0,v = -1;
	for(int i=0;i<n;i++){
		if(i == u)
			continue;
		int cur = query(u,i);
		if(cur > mx){
			mx = cur; 
			v = i;
		}
	}
	assert(v!=-1);
	return v;
}

int hubDistance(int N, int sub){
	n = N;
	int a = far(0);
	int b = far(a);
	far(b);
	int len = query(a,b);
	R = 2e9;
	for(int i=0;i<n;i++){
		if(a == i || b == i)
			continue;
		int disa = query(i,a);
		int disb = query(i,b);
		int cur = disa + disb - len;
		cur/=2;
		R = min(R,max(disa,disb) - cur);
	}
	return R;
}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:35:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int N, int sub){
                            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 1068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1152 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -