結果

問題 No.1560 majority x majority
ユーザー H3PO4H3PO4
提出日時 2022-11-27 16:27:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,769 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 81,656 KB
最終ジャッジ日時 2024-04-14 23:53:33
合計ジャッジ時間 12,678 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,769 ms
81,656 KB
testcase_01 AC 1,768 ms
81,432 KB
testcase_02 AC 37 ms
53,760 KB
testcase_03 AC 810 ms
80,128 KB
testcase_04 AC 101 ms
78,620 KB
testcase_05 AC 1,484 ms
80,640 KB
testcase_06 AC 172 ms
77,276 KB
testcase_07 AC 88 ms
76,972 KB
testcase_08 AC 673 ms
79,608 KB
testcase_09 AC 279 ms
77,784 KB
testcase_10 AC 46 ms
64,392 KB
testcase_11 AC 100 ms
77,164 KB
testcase_12 AC 63 ms
73,064 KB
testcase_13 AC 114 ms
77,308 KB
testcase_14 AC 70 ms
76,872 KB
testcase_15 AC 245 ms
77,840 KB
testcase_16 AC 57 ms
70,364 KB
testcase_17 AC 704 ms
79,152 KB
testcase_18 AC 184 ms
77,680 KB
testcase_19 AC 47 ms
63,436 KB
testcase_20 AC 58 ms
70,016 KB
testcase_21 AC 60 ms
72,480 KB
testcase_22 AC 317 ms
77,896 KB
testcase_23 AC 54 ms
69,848 KB
testcase_24 AC 53 ms
66,804 KB
testcase_25 AC 277 ms
77,708 KB
testcase_26 AC 38 ms
53,700 KB
testcase_27 AC 38 ms
52,200 KB
testcase_28 AC 37 ms
53,380 KB
testcase_29 AC 39 ms
54,616 KB
testcase_30 AC 54 ms
66,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline


def bit_count(n):
    return bin(n).count("1")


N, M = map(int, input().split())
S = tuple(tuple(map(int, input().split())) for _ in range(N))
Sb = [sum(1 << x for x in range(N) if S[x][i]) for i in range(M)]
dp = [0] * (1 << M)
alive = [0 for _ in range(1 << M)]
dp[0] = 1
alive[0] = (1 << N) - 1
for b in range(1 << M):
    for i in range(M):
        if (b >> i) & 1:
            continue
        affirmative = bit_count(alive[b] & Sb[i])
        c = b | (1 << i)
        if affirmative >= bit_count(alive[b]) - affirmative:
            dp[c] += dp[b]
        if not alive[c]:
            alive[c] = alive[b] & Sb[i]
print(dp[-1])
0