結果

問題 No.845 最長の切符
ユーザー pengincoalitionpengincoalition
提出日時 2019-07-04 21:11:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 670 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 30,248 KB
最終ジャッジ日時 2023-10-19 10:36:33
合計ジャッジ時間 7,359 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,336 KB
testcase_01 AC 33 ms
10,324 KB
testcase_02 AC 41 ms
10,608 KB
testcase_03 AC 33 ms
10,312 KB
testcase_04 RE -
testcase_05 AC 32 ms
10,312 KB
testcase_06 AC 32 ms
10,312 KB
testcase_07 AC 32 ms
10,316 KB
testcase_08 AC 41 ms
10,472 KB
testcase_09 AC 33 ms
10,340 KB
testcase_10 AC 98 ms
11,060 KB
testcase_11 AC 40 ms
10,384 KB
testcase_12 AC 57 ms
10,660 KB
testcase_13 AC 36 ms
10,376 KB
testcase_14 AC 46 ms
10,644 KB
testcase_15 AC 1,441 ms
17,276 KB
testcase_16 TLE -
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 #

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