結果

問題 No.845 最長の切符
ユーザー rusa6111rusa6111
提出日時 2019-06-28 21:46:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 483 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 78,104 KB
最終ジャッジ日時 2023-09-14 21:47:56
合計ジャッジ時間 6,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,600 KB
testcase_01 AC 71 ms
71,396 KB
testcase_02 AC 76 ms
76,220 KB
testcase_03 AC 71 ms
71,260 KB
testcase_04 AC 72 ms
71,248 KB
testcase_05 AC 71 ms
71,408 KB
testcase_06 AC 70 ms
71,288 KB
testcase_07 AC 72 ms
75,372 KB
testcase_08 AC 312 ms
78,104 KB
testcase_09 AC 109 ms
77,804 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=tuple(map(int,input().split()))
way=[set() for i in range(n)]
for i in range(m):
	inp=tuple(map(int,input().split()))
	way[inp[0]-1].add((inp[1]-1,inp[2]))
	way[inp[1]-1].add((inp[0]-1,inp[2]))
def longest(fr,to,without):
	maxd=0
	for i in way[fr]:
		if not (i[0] in without):
			d=i[1]+longest(i[0],to,without+[fr])
			if d>maxd:
				maxd=d
	return maxd
maxd=0
for i in range(n):
	for j in range(m):
		if i==j:
			continue
		d=longest(i,j,[])
		if maxd<d:
			maxd=d
print(maxd)
0