Submission #233267

# Submission time Handle Problem Language Result Execution time Memory
233267 2020-05-20T07:54:32 Z mieszko11b Towns (IOI15_towns) C++14
25 / 100
27 ms 1152 KB
#include "towns.h"
#include <bits/stdc++.h>

using namespace std;

int v = 0, s, t;
int distv[120], dists[120];

int hubDistance(int N, int sub) {
	int maxv = 0;
	for(int i = 0 ; i < N ; i++) {
		distv[i] = getDistance(v, i);
		maxv = max(maxv, distv[i]);
	}
	
	for(int i = 0 ; i < N ; i++)
		if(distv[i] == maxv)
			s = i;
			
	int dsv = maxv;
			
	maxv = 0;
	for(int i = 0 ; i < N ; i++) {
		dists[i] = getDistance(s, i);
		maxv = max(maxv, dists[i]);
	}
	
	int d = maxv;
	
	for(int i = 0 ; i < N ; i++)
		if(dists[i] == maxv)
			t = i;	

	int res = 1e9;
	for(int i = 0 ; i < N ; i++) {
		int a = (dists[i] + dsv - distv[i]) / 2;
		int b = dsv - a;
		res = min(res, max({a, b, d - a}));
		//~ cout << i << " " << res << endl;
	}
	
	return res;
}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:9:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int N, int sub) {
                            ^~~
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1024 KB Output is correct
2 Correct 19 ms 896 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 25 ms 896 KB Output is correct
5 Correct 25 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1024 KB Output is correct
2 Correct 20 ms 768 KB Output is correct
3 Correct 25 ms 896 KB Output is correct
4 Correct 25 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1152 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -