結果

問題 No.845 最長の切符
ユーザー pengincoalitionpengincoalition
提出日時 2019-07-04 21:11:01
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 670 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 31,744 KB
最終ジャッジ日時 2024-09-19 06:46:52
合計ジャッジ時間 7,215 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 RE * 1 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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])


dp_s=[]

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):
                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]))


0