結果

問題 No.1560 majority x majority
ユーザー H3PO4H3PO4
提出日時 2022-11-27 16:20:32
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 583 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 253,324 KB
最終ジャッジ日時 2023-07-27 11:31:37
合計ジャッジ時間 12,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 1,302 ms
165,176 KB
testcase_02 AC 72 ms
71,360 KB
testcase_03 AC 194 ms
82,720 KB
testcase_04 AC 138 ms
80,336 KB
testcase_05 AC 212 ms
84,440 KB
testcase_06 AC 145 ms
79,688 KB
testcase_07 AC 111 ms
78,268 KB
testcase_08 AC 182 ms
81,892 KB
testcase_09 AC 154 ms
79,568 KB
testcase_10 AC 86 ms
76,588 KB
testcase_11 AC 118 ms
78,124 KB
testcase_12 AC 105 ms
77,792 KB
testcase_13 AC 123 ms
78,424 KB
testcase_14 AC 105 ms
78,020 KB
testcase_15 AC 151 ms
79,440 KB
testcase_16 AC 97 ms
77,204 KB
testcase_17 AC 223 ms
83,676 KB
testcase_18 AC 145 ms
79,940 KB
testcase_19 AC 85 ms
76,648 KB
testcase_20 AC 98 ms
77,292 KB
testcase_21 AC 96 ms
77,172 KB
testcase_22 AC 182 ms
82,512 KB
testcase_23 AC 86 ms
76,676 KB
testcase_24 AC 99 ms
77,172 KB
testcase_25 AC 173 ms
81,176 KB
testcase_26 AC 72 ms
71,336 KB
testcase_27 AC 73 ms
71,172 KB
testcase_28 AC 74 ms
71,156 KB
testcase_29 AC 75 ms
71,496 KB
testcase_30 AC 94 ms
76,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline

N, M = map(int, input().split())
S = tuple(tuple(map(int, input().split())) for _ in range(N))

dp = [0] * (1 << M)
alive = [[] for _ in range(1 << M)]
dp[0] = 1
alive[0] = list(range(N))
for b in range(1 << M):
    for i in range(M):
        if (b >> i) & 1:
            continue
        affirmative = sum(S[x][i] for x in alive[b])
        c = b | (1 << i)
        if affirmative >= len(alive[b]) - affirmative:
            dp[c] += dp[b]
        if not alive[c]:
            alive[c] = [x for x in alive[b] if S[x][i]]
print(dp[-1])
0