记录编号 392325 评测结果 AAAAAAAA
题目名称 服务点设置 最终得分 100
用户昵称 GravatarHeHe 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2017-04-07 19:16:18 内存使用 0.00 MiB
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

const int MAXN = 110;
const int INF = 0x7fffffff;

const inline int in(void){
	char tmp = getchar();
	int res = 0;
	while(!isdigit(tmp))tmp = getchar();
	while(isdigit(tmp))
		res = (res + (res << 2) << 1) + (tmp ^ 48),
		tmp = getchar();
	return res;
}
template<typename T>
T my_min(const T& a, const T& b){
	if(a < b)return a;
	return b;
}

int N, M;
int dis[MAXN][MAXN];

void *Main(void){
#ifndef LOCAL
	freopen("djsa.in", "r", stdin);
	freopen("djsa.out", "w", stdout);
#endif
	memset(dis, 0x7f / 2, sizeof(dis));
	for(int i = 0; i < MAXN; ++i)dis[i][i] = 0;
	
	N = in(), M = in();
	for(int i = 1, a, b, c; i <= M; ++i){
		a = in(), b = in(), c = in();
		dis[a][b] = dis[b][a] = c;
	}
	
	for(int k = 0; k < N; ++k){
		for(int i = 0; i < N; ++i){
			for(int j = 0; j < N; ++j){
				dis[i][j] = my_min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	
	int ans_min = INF, tmp_max;
	int ans = 1;
	for(int i = 0; i < N; ++i){
		tmp_max = -1;
		for(int j = 0; j < N; ++j){
			if(dis[i][j] > tmp_max)tmp_max = dis[i][j];
		}
		if(tmp_max < ans_min){
			ans_min = tmp_max, ans = i;
		}
	}
	
	printf("%d", ans);
	
	return NULL;
}void *Main_(Main());int main(){;}