結果

問題 No.1912 Get together 2
ユーザー shotoyooshotoyoo
提出日時 2021-09-21 00:17:51
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 928 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 103,732 KB
最終ジャッジ日時 2023-09-06 06:42:24
合計ジャッジ時間 6,186 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
75,796 KB
testcase_01 AC 68 ms
71,456 KB
testcase_02 AC 71 ms
71,344 KB
testcase_03 AC 84 ms
76,424 KB
testcase_04 AC 66 ms
71,184 KB
testcase_05 AC 68 ms
70,996 KB
testcase_06 AC 72 ms
75,756 KB
testcase_07 AC 77 ms
76,396 KB
testcase_08 AC 135 ms
80,212 KB
testcase_09 AC 125 ms
78,432 KB
testcase_10 AC 141 ms
82,056 KB
testcase_11 AC 134 ms
79,904 KB
testcase_12 AC 177 ms
82,160 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,m = list(map(int, input().split()))
vs = list(map(int, input().split()))
vals = [0]*(1<<m)
for i in range(n):
    s = input()
    b = int(s.replace("o", "1").replace("x", "0")[::-1], 2)
    vals[b] += vs[i]
size = [0]*(1<<m)
for b in range(1<<m):
    sb = b
    v = 0
    while True:
        # 部分集合に対する操作はここに
        v += vals[sb]
        sb = (sb-1) & b
        if sb==b:
            break
        # print(bin(sb)) # 真部分集合に対す操作はここに
    size[b] = v
dp = [0]*(1<<m)
for b in range(1<<m):
    val = dp[b]
    for i in range(m):
        if b>>i&1:
            continue
        nb = b|(1<<i)
        dp[nb] = max(dp[nb], val + (size[nb] - size[b])**2)
ans = dp[(1<<m)-1]
print(ans)
0