結果

問題 No.1560 majority x majority
ユーザー H3PO4H3PO4
提出日時 2022-11-27 16:35:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 854 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 63,632 KB
最終ジャッジ日時 2024-04-14 23:58:06
合計ジャッジ時間 20,549 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 854 ms
63,632 KB
testcase_01 AC 820 ms
63,580 KB
testcase_02 AC 517 ms
44,212 KB
testcase_03 AC 817 ms
62,020 KB
testcase_04 AC 786 ms
60,308 KB
testcase_05 AC 795 ms
60,020 KB
testcase_06 AC 631 ms
44,220 KB
testcase_07 AC 540 ms
44,216 KB
testcase_08 AC 651 ms
51,344 KB
testcase_09 AC 662 ms
46,980 KB
testcase_10 AC 522 ms
44,336 KB
testcase_11 AC 531 ms
43,964 KB
testcase_12 AC 524 ms
43,956 KB
testcase_13 AC 533 ms
44,336 KB
testcase_14 AC 522 ms
43,952 KB
testcase_15 AC 641 ms
46,000 KB
testcase_16 AC 520 ms
44,208 KB
testcase_17 AC 645 ms
51,508 KB
testcase_18 AC 563 ms
43,828 KB
testcase_19 AC 524 ms
43,952 KB
testcase_20 AC 519 ms
44,084 KB
testcase_21 AC 527 ms
44,344 KB
testcase_22 AC 573 ms
46,864 KB
testcase_23 AC 520 ms
43,960 KB
testcase_24 AC 518 ms
43,824 KB
testcase_25 AC 573 ms
46,392 KB
testcase_26 AC 523 ms
43,988 KB
testcase_27 AC 520 ms
44,076 KB
testcase_28 AC 515 ms
43,960 KB
testcase_29 AC 517 ms
43,952 KB
testcase_30 AC 522 ms
43,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

input = sys.stdin.buffer.readline

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

dp = [0] * (1 << M)
alive = np.zeros((1 << M, N), dtype=bool)
dp[0] = 1
alive[0] = True
for b in range(1 << M):
    for i in range(M):
        if (b >> i) & 1:
            continue
        affirmative = alive[b] & S[:, i]
        affirmative_count = np.count_nonzero(affirmative)
        c = b | (1 << i)
        if affirmative_count >= np.count_nonzero(alive[b]) - affirmative_count:
            dp[c] += dp[b]
        alive[c] = affirmative
print(dp[-1])
0