开始: 2023-09-24 09:00:00

0923日常周赛

结束: 2023-09-30 08:55:00
当前  2025-01-24 17:59:30  类型: IOI  状态: 已经结束 

P3. Remembering the Days
描述

A region has N towns numbered 1 to N, and M roads numbered 1 to M.

The i-th road connects town Ai and town Bi bidirectionally with length Ci .

Find the maximum possible total length of the roads you traverse when starting from a town of your choice and getting to another town without passing through the same town more than once.

有一个 N 个点 M 条边的无向图。

i 条边的长度为 C_i

求出图中最长的简单路径的长度。


输入

The input is given from Standard Input in the following format:

N M

A1 B1 C1

A2 B2 C2

...

AM BM CM

输出



Print the answer.




样例

输入

4 4
1 2 1
2 3 10
1 3 100
1 4 1000

输出

1110

输入

10 1
5 9 1

输出

1

输入

10 13
1 2 1
1 10 1
2 3 1
3 4 4
4 7 2
4 8 1
5 8 1
5 9 3
6 8 1
6 9 5
7 8 1
7 9 4
9 10 3

输出

20
提示

- 2\ \leq\ N\ \leq\ 10

- 1\ \leq\ M\ \leq\ \frac{N(N-1)}{2}

- 1\leq\ A_i\ <\ B_i\ \leq\ N

- 1\leq\ C_i\ \leq\ 10^8

提交

题目参数
时间限制 1 秒
内存限制 128 MB
提交