結果
問題 |
No.845 最長の切符
|
ユーザー |
![]() |
提出日時 | 2019-06-28 21:46:06 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 483 bytes |
コンパイル時間 | 220 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 86,912 KB |
最終ジャッジ日時 | 2024-07-02 04:33:48 |
合計ジャッジ時間 | 5,881 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 TLE * 1 -- * 19 |
ソースコード
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)