记录编号 42702 评测结果 AAAAAAAA
题目名称 服务点设置 最终得分 100
用户昵称 Gravatarondelett 是否通过 通过
代码语言 C++ 运行时间 0.008 s
提交时间 2012-09-28 10:01:07 内存使用 0.32 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>

using namespace std;

const int MAXN = 120;
int n, m;
int mat[MAXN][MAXN];
const int INF = 88888888;

void floyd()
{
	for (int k = 0; k < n; k++)
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j]);
}

int main()
{
	freopen("djsa.in", "r", stdin);
	freopen("djsa.out", "w", stdout);
	int u, v, w;

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			mat[i][j] = (i == j ? 0 : INF);
	
	while (m--) {
		scanf("%d%d%d", &u, &v, &w);
//		if (w < mat[v][u])
		mat[v][u] = mat[u][v] = w;
	}
	floyd();
	int ans = -1;
	int mins = INF;
	for (int i = 0; i < n; ++i) {
		int maxs = -1;
		for (int j = 0; j < n; ++j) {
			if (j == i)
				continue;
			if (mat[i][j] > maxs)
				maxs = mat[i][j];
		}
		if (maxs < mins) {
			mins = maxs;
			ans = i;
		}
	}
	printf("%d\n", ans);

	return 0;
}