結果

問題 No.519 アイドルユニット
ユーザー convexineqconvexineq
提出日時 2021-02-18 11:15:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 502 bytes
コンパイル時間 1,086 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 89,360 KB
最終ジャッジ日時 2023-10-12 19:55:05
合計ジャッジ時間 5,960 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 178 ms
89,340 KB
testcase_01 AC 191 ms
89,168 KB
testcase_02 AC 141 ms
81,244 KB
testcase_03 AC 110 ms
77,892 KB
testcase_04 AC 91 ms
71,576 KB
testcase_05 AC 91 ms
71,744 KB
testcase_06 AC 92 ms
71,836 KB
testcase_07 AC 91 ms
71,984 KB
testcase_08 AC 102 ms
77,420 KB
testcase_09 AC 108 ms
78,000 KB
testcase_10 AC 108 ms
77,948 KB
testcase_11 AC 112 ms
77,688 KB
testcase_12 AC 96 ms
71,712 KB
testcase_13 AC 113 ms
77,612 KB
testcase_14 AC 114 ms
77,800 KB
testcase_15 AC 113 ms
77,948 KB
testcase_16 AC 113 ms
78,068 KB
testcase_17 AC 113 ms
78,224 KB
testcase_18 AC 113 ms
77,900 KB
testcase_19 AC 111 ms
78,064 KB
testcase_20 AC 113 ms
77,944 KB
testcase_21 AC 112 ms
77,804 KB
testcase_22 AC 112 ms
78,224 KB
testcase_23 AC 113 ms
78,024 KB
testcase_24 AC 121 ms
78,640 KB
testcase_25 AC 121 ms
78,516 KB
testcase_26 AC 120 ms
78,476 KB
testcase_27 AC 119 ms
78,660 KB
testcase_28 AC 120 ms
78,336 KB
testcase_29 AC 188 ms
89,360 KB
testcase_30 AC 198 ms
89,092 KB
testcase_31 AC 197 ms
89,192 KB
testcase_32 AC 187 ms
89,192 KB
testcase_33 AC 94 ms
71,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
N = 1<<n
INF = 1<<30
dp = {0:0}
from collections import deque
q = deque([0])
while q:
    mask = q.popleft()
    v = (~mask&-(~mask)).bit_length() - 1
    for w in range(v+1,n):
        if mask>>w&1: continue
        nmask = mask | ((1<<w)+(1<<v))
        if nmask in dp:
            dp[nmask] = max(dp[nmask], dp[mask] + d[v][w])
        else:
            dp[nmask] = dp[mask] + d[v][w]
            q.append(nmask)
print(dp[N-1])
0