結果

問題 No.845 最長の切符
ユーザー rusa6111rusa6111
提出日時 2019-06-28 21:48:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 86,564 KB
実行使用メモリ 87,904 KB
最終ジャッジ日時 2023-09-14 21:50:23
合計ジャッジ時間 6,898 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,356 KB
testcase_01 WA -
testcase_02 AC 73 ms
71,292 KB
testcase_03 AC 72 ms
71,304 KB
testcase_04 AC 71 ms
71,456 KB
testcase_05 AC 72 ms
71,352 KB
testcase_06 AC 71 ms
71,348 KB
testcase_07 AC 73 ms
71,144 KB
testcase_08 AC 302 ms
78,296 KB
testcase_09 AC 105 ms
77,628 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(i+1,m):
		d=longest(i,j,[])
		if maxd<d:
			maxd=d
print(maxd)
0