結果

問題 No.1560 majority x majority
ユーザー H3PO4H3PO4
提出日時 2022-11-27 16:20:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 583 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 252,300 KB
最終ジャッジ日時 2024-04-14 23:49:12
合計ジャッジ時間 10,211 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 1,255 ms
163,072 KB
testcase_02 AC 38 ms
52,724 KB
testcase_03 AC 164 ms
81,536 KB
testcase_04 AC 110 ms
79,132 KB
testcase_05 AC 188 ms
82,984 KB
testcase_06 AC 111 ms
77,928 KB
testcase_07 AC 79 ms
77,184 KB
testcase_08 AC 151 ms
80,092 KB
testcase_09 AC 123 ms
77,944 KB
testcase_10 AC 52 ms
64,844 KB
testcase_11 AC 88 ms
77,020 KB
testcase_12 AC 70 ms
73,380 KB
testcase_13 AC 93 ms
77,712 KB
testcase_14 AC 71 ms
75,132 KB
testcase_15 AC 120 ms
77,956 KB
testcase_16 AC 61 ms
70,044 KB
testcase_17 AC 190 ms
82,580 KB
testcase_18 AC 113 ms
79,220 KB
testcase_19 AC 50 ms
63,632 KB
testcase_20 AC 64 ms
72,948 KB
testcase_21 AC 62 ms
71,544 KB
testcase_22 AC 152 ms
81,104 KB
testcase_23 AC 53 ms
66,732 KB
testcase_24 AC 64 ms
70,612 KB
testcase_25 AC 140 ms
80,544 KB
testcase_26 AC 39 ms
52,692 KB
testcase_27 AC 38 ms
53,640 KB
testcase_28 AC 39 ms
52,792 KB
testcase_29 AC 39 ms
52,744 KB
testcase_30 AC 57 ms
66,356 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