Submission #58295

#TimeUsernameProblemLanguageResultExecution timeMemory
58295E869120Towns (IOI15_towns)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <cmath>
using namespace std;

int Weight[111][111], NN, TT, SB, c[111];

//int getDistance(int p1, int p2) { return Weight[p1][p2]; }

int hubDistance(int N, int sub) {
	int maxn1 = 0, u = 0;
	for (int i = 1; i <= N; i++) { int V = getDistance(1, i); if (V > maxn1) { maxn1 = V; u = i; } }
	int maxn2 = 0, v = 0;
	for (int i = 1; i <= N; i++) { int V = getDistance(u, i); if (V > maxn2) { maxn2 = V; v = i; } c[i] = V; }

	for (int i = 1; i <= N; i++) c[i] -= getDistance(v, i);

	int ret = (1 << 30), maxid = 0;
	for (int i = 1; i <= N; i++) { if (abs(c[i]) < ret) { ret = abs(c[i]); maxid = i; } }

	int p[3] = { 0,0,0 }, R = c[maxid], S = (maxn2 + ret) / 2;
	for (int i = 1; i <= N; i++) {
		if (c[i] < R) p[0]++;
		if (c[i] == R) p[1]++;
		if (c[i] > R) p[2]++;
	}
	if (p[0] > (N / 2) || p[1] > (N / 2) || p[2] > (N / 2)) return -S;
	return S;
}

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:11:41: error: 'getDistance' was not declared in this scope
  for (int i = 1; i <= N; i++) { int V = getDistance(1, i); if (V > maxn1) { maxn1 = V; u = i; } }
                                         ^~~~~~~~~~~
towns.cpp:11:41: note: suggested alternative: 'hubDistance'
  for (int i = 1; i <= N; i++) { int V = getDistance(1, i); if (V > maxn1) { maxn1 = V; u = i; } }
                                         ^~~~~~~~~~~
                                         hubDistance
towns.cpp:13:41: error: 'getDistance' was not declared in this scope
  for (int i = 1; i <= N; i++) { int V = getDistance(u, i); if (V > maxn2) { maxn2 = V; v = i; } c[i] = V; }
                                         ^~~~~~~~~~~
towns.cpp:13:41: note: suggested alternative: 'hubDistance'
  for (int i = 1; i <= N; i++) { int V = getDistance(u, i); if (V > maxn2) { maxn2 = V; v = i; } c[i] = V; }
                                         ^~~~~~~~~~~
                                         hubDistance
towns.cpp:15:39: error: 'getDistance' was not declared in this scope
  for (int i = 1; i <= N; i++) c[i] -= getDistance(v, i);
                                       ^~~~~~~~~~~
towns.cpp:15:39: note: suggested alternative: 'hubDistance'
  for (int i = 1; i <= N; i++) c[i] -= getDistance(v, i);
                                       ^~~~~~~~~~~
                                       hubDistance
towns.cpp:9:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int N, int sub) {
                            ^~~