Submission #96560

# Submission time Handle Problem Language Result Execution time Memory
96560 2019-02-10T09:58:10 Z rubenvd Towns (IOI15_towns) C++14
13 / 100
19 ms 888 KB
#include <bits/stdc++.h>
#include "towns.h"
using namespace std;
/*int dis[110][110];

int getDistance( int i, int j ){
	return dis[i][j];
}*/

int hubDistance( int n, int sub ){
	int m[n][n], s, t, maxd = -1;
	for( int i = 0; i < n; ++i ){
		m[i][i] = 0;
		for( int j = i+1; j < n; ++j ){
			m[i][j] = getDistance(i,j);
			m[j][i] = m[i][j];

			if( m[i][j] > maxd ){
				s = i;
				t = j;
				maxd = m[i][j];
			}
		}
	}

	int mini = 1e7+5;
	for( int i = 0; i < n; ++i ){
		if( i != s && i != t ){
			int z = (m[i][t] - m[i][s] - maxd)/-2;
			int x = maxd - z, y = m[i][s] - z; 
			//cout << s << " <-> " << t << " <-> " << i << "   " << z << " " << y << " " << x << endl;
			mini = min(mini, max(x, z));
		}
	}
	return mini;
}

/*int main(){
	int sb, tc, n;
	cin >> sb >> tc >> n;

	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			cin >> dis[i][j];
		}
	}
	cout << hubDistance(n, sb) << endl;
	return 0;
}*/

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:30:22: warning: unused variable 'y' [-Wunused-variable]
    int x = maxd - z, y = m[i][s] - z; 
                      ^
towns.cpp:10:29: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance( int n, int sub ){
                             ^~~
towns.cpp:28:9: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if( i != s && i != t ){
       ~~^~~~
towns.cpp:28:19: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if( i != s && i != t ){
                 ~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 19 ms 376 KB Output is correct
2 Correct 14 ms 888 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 19 ms 888 KB Output is correct
5 Correct 18 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -