結果
| 問題 | No.1560 majority x majority |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-27 16:35:35 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 916 ms / 2,000 ms |
| コード長 | 641 bytes |
| 記録 | |
| コンパイル時間 | 343 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 54,596 KB |
| 最終ジャッジ日時 | 2026-04-20 03:32:22 |
| 合計ジャッジ時間 | 25,450 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 26 |
ソースコード
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])