結果
問題 |
No.845 最長の切符
|
ユーザー |
|
提出日時 | 2019-07-04 21:23:39 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 672 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 91,904 KB |
最終ジャッジ日時 | 2024-09-19 06:47:23 |
合計ジャッジ時間 | 6,447 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 TLE * 2 |
ソースコード
import copy N,M=tuple(map(int,input().split(' '))) x={} for i in range(M): temp1,temp2,temp3=tuple(map(int,input("").split(" "))) if temp2-1 not in x: x[temp2-1]=[] if temp1-1 not in x: x[temp1-1]=[] x[temp2-1].append([temp3,temp1-1]) x[temp1-1].append([temp3,temp2-1]) if True: dp=[[0 for j in range(N)] for i in range(1<<N)] for i2 in range(0,1<<N): for i3 in range(N): if i2&(1<<i3) and i3 in x: for j in x[i3]: if not(i2&(1<<j[1])): dp[i2|(1<<j[1])][j[1]]=max([dp[i2][i3]+j[0],dp[i2|(1<<j[1])][j[1]]]) print(max([max(e) for e in dp]))