답안 #58296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58296 2018-07-17T11:49:32 Z E869120 도시들 (IOI15_towns) C++14
0 / 100
35 ms 3752 KB
#include "towns.h"
#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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:10:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int N, int sub) {
                            ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 1572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 2076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 2948 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 3296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 3752 KB Output isn't correct
2 Halted 0 ms 0 KB -