結果

問題 No.845 最長の切符
ユーザー 6soukiti296soukiti29
提出日時 2019-06-28 23:19:47
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 1,175 bytes
コンパイル時間 4,291 ms
コンパイル使用メモリ 68,316 KB
実行使用メモリ 133,576 KB
最終ジャッジ日時 2023-09-14 22:40:58
合計ジャッジ時間 12,865 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
21,428 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 5 ms
21,564 KB
testcase_06 AC 6 ms
21,420 KB
testcase_07 AC 6 ms
21,420 KB
testcase_08 AC 15 ms
56,260 KB
testcase_09 AC 7 ms
29,600 KB
testcase_10 AC 26 ms
68,600 KB
testcase_11 AC 9 ms
33,884 KB
testcase_12 AC 18 ms
62,444 KB
testcase_13 AC 9 ms
33,724 KB
testcase_14 AC 17 ms
62,508 KB
testcase_15 AC 188 ms
75,676 KB
testcase_16 AC 1,005 ms
103,356 KB
testcase_17 AC 190 ms
116,048 KB
testcase_18 AC 431 ms
122,912 KB
testcase_19 AC 86 ms
107,656 KB
testcase_20 AC 995 ms
133,528 KB
testcase_21 AC 996 ms
133,432 KB
testcase_22 AC 188 ms
116,156 KB
testcase_23 AC 42 ms
74,756 KB
testcase_24 AC 1,007 ms
133,576 KB
testcase_25 AC 2 ms
5,004 KB
testcase_26 AC 980 ms
133,376 KB
testcase_27 AC 3 ms
7,084 KB
testcase_28 AC 984 ms
133,400 KB
testcase_29 AC 2 ms
5,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,algorithm
var
    N, M, a, b, c: int
    hyou : array[16, array[16, int]]
    s : int
    ans : int
    dp : array[16, array[16, array[(1 shl 16), int]]]
(N, M) = stdin.readline.split.map(parseInt)
var
    used : array[17, bool]
for i in 0..<M:
    (a, b, c) = stdin.readline.split.map(parseInt)
    a -= 1
    b -= 1
    hyou[a][b] = max(hyou[a][b], c)
    hyou[b][a] = max(hyou[b][a], c)

for B in 0..<(1 shl N):
    for s in 0..<N:
        for g in 0..<N:
            if B == 0:
                var nb = ((1 shl s) or (1 shl g))
                dp[s][g][nb] = hyou[s][g]
                dp[g][s][nb] = hyou[g][s]
            if (B and (1 shl s)) > 0 and (B and (1 shl g)) > 0:
                for k in 0..<N:
                    if (B and (1 shl k)) > 0:
                        continue
                    var nb = ((1 shl k) or B)
                    dp[s][k][nb] = max(dp[s][k][nb], dp[s][g][B] + hyou[g][k])
                    dp[k][g][nb] = max(dp[k][g][nb], dp[s][g][B] + hyou[k][s])
                    ans = max(dp[k][g][nb], ans)
                    ans = max(dp[s][k][nb], ans)

echo ans


                    
                    



0