結果

問題 No.845 最長の切符
ユーザー pengincoalitionpengincoalition
提出日時 2019-07-04 21:23:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 672 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 81,476 KB
実行使用メモリ 90,492 KB
最終ジャッジ日時 2023-10-19 10:37:04
合計ジャッジ時間 13,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,408 KB
testcase_01 AC 59 ms
58,896 KB
testcase_02 AC 71 ms
72,892 KB
testcase_03 AC 45 ms
53,408 KB
testcase_04 AC 44 ms
53,408 KB
testcase_05 AC 44 ms
53,408 KB
testcase_06 AC 44 ms
53,408 KB
testcase_07 AC 45 ms
53,408 KB
testcase_08 AC 66 ms
70,576 KB
testcase_09 AC 52 ms
61,636 KB
testcase_10 AC 91 ms
76,536 KB
testcase_11 AC 65 ms
70,440 KB
testcase_12 AC 80 ms
76,152 KB
testcase_13 AC 63 ms
68,404 KB
testcase_14 AC 67 ms
72,648 KB
testcase_15 AC 224 ms
79,204 KB
testcase_16 TLE -
testcase_17 AC 947 ms
79,552 KB
testcase_18 AC 630 ms
82,656 KB
testcase_19 AC 222 ms
77,636 KB
testcase_20 AC 929 ms
89,904 KB
testcase_21 AC 564 ms
89,872 KB
testcase_22 AC 738 ms
79,364 KB
testcase_23 AC 228 ms
76,932 KB
testcase_24 AC 2,938 ms
90,144 KB
testcase_25 AC 43 ms
53,408 KB
testcase_26 AC 134 ms
89,852 KB
testcase_27 AC 43 ms
53,408 KB
testcase_28 AC 197 ms
89,916 KB
testcase_29 AC 43 ms
53,408 KB
権限があれば一括ダウンロードができます

ソースコード

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


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

0