結果

問題 No.1560 majority x majority
ユーザー convexineqconvexineq
提出日時 2021-07-19 06:55:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 86,440 KB
実行使用メモリ 80,748 KB
最終ジャッジ日時 2023-09-23 15:31:03
合計ジャッジ時間 5,444 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 227 ms
80,192 KB
testcase_01 AC 228 ms
80,748 KB
testcase_02 AC 67 ms
71,156 KB
testcase_03 AC 163 ms
79,028 KB
testcase_04 AC 105 ms
77,240 KB
testcase_05 AC 201 ms
79,864 KB
testcase_06 AC 100 ms
77,760 KB
testcase_07 AC 90 ms
76,876 KB
testcase_08 AC 154 ms
78,496 KB
testcase_09 AC 111 ms
77,604 KB
testcase_10 AC 91 ms
76,440 KB
testcase_11 AC 97 ms
77,304 KB
testcase_12 AC 86 ms
76,416 KB
testcase_13 AC 94 ms
77,364 KB
testcase_14 AC 91 ms
77,308 KB
testcase_15 AC 109 ms
78,328 KB
testcase_16 AC 92 ms
76,476 KB
testcase_17 AC 149 ms
78,500 KB
testcase_18 AC 106 ms
77,104 KB
testcase_19 AC 94 ms
76,660 KB
testcase_20 AC 95 ms
76,648 KB
testcase_21 AC 97 ms
77,088 KB
testcase_22 AC 123 ms
77,740 KB
testcase_23 AC 104 ms
76,468 KB
testcase_24 AC 96 ms
76,524 KB
testcase_25 AC 118 ms
77,540 KB
testcase_26 AC 67 ms
71,084 KB
testcase_27 AC 70 ms
71,120 KB
testcase_28 AC 66 ms
71,360 KB
testcase_29 AC 68 ms
71,076 KB
testcase_30 AC 76 ms
76,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
r = [0]*m
for i in range(n):
    for j,rj in enumerate(map(int,input().split())):
        r[j] |= rj<<i

M = 1<<m
dp = [(1<<n)-1]
for i in range(m):
    dp += [x&r[i] for x in dp]
*cnt, = map(lambda s:bin(s).count("1"), dp)

A = [0]*M
A[0] = 1
for S in range(M):
    for i in range(m):
        nS = S|1<<i
        if S>>i&1==0 and cnt[S] <= 2*cnt[nS]:
            A[nS] += A[S]
print(A[-1])
0