結果

問題 No.1560 majority x majority
ユーザー convexineqconvexineq
提出日時 2021-07-19 06:39:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 487 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 1,189 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 238,328 KB
最終ジャッジ日時 2023-09-23 14:46:48
合計ジャッジ時間 8,432 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 400 ms
238,328 KB
testcase_01 AC 487 ms
237,420 KB
testcase_02 AC 65 ms
71,108 KB
testcase_03 AC 344 ms
214,396 KB
testcase_04 AC 298 ms
193,240 KB
testcase_05 AC 303 ms
192,532 KB
testcase_06 AC 113 ms
84,208 KB
testcase_07 AC 92 ms
76,716 KB
testcase_08 AC 196 ms
123,500 KB
testcase_09 AC 141 ms
103,964 KB
testcase_10 AC 92 ms
76,988 KB
testcase_11 AC 102 ms
80,584 KB
testcase_12 AC 89 ms
76,740 KB
testcase_13 AC 110 ms
82,036 KB
testcase_14 AC 95 ms
77,112 KB
testcase_15 AC 142 ms
83,560 KB
testcase_16 AC 92 ms
76,884 KB
testcase_17 AC 283 ms
123,776 KB
testcase_18 AC 118 ms
79,752 KB
testcase_19 AC 93 ms
76,748 KB
testcase_20 AC 89 ms
76,504 KB
testcase_21 AC 93 ms
76,792 KB
testcase_22 AC 152 ms
100,520 KB
testcase_23 AC 91 ms
76,872 KB
testcase_24 AC 89 ms
76,756 KB
testcase_25 AC 173 ms
99,668 KB
testcase_26 AC 68 ms
71,296 KB
testcase_27 AC 67 ms
71,120 KB
testcase_28 AC 69 ms
71,268 KB
testcase_29 AC 69 ms
71,100 KB
testcase_30 AC 78 ms
76,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

M = 1<<m
dp = [None]*M
dp[0] = [1]*n
cnt = [0]*M
cnt[0] = n
for i in range(m):
    for j in range(1<<i):
        v = 0
        ndp = [0]*n
        for k in range(n):
            if dp[j][k] & res[i][k]:
                v += 1
                ndp[k] = 1
        dp[(1<<i)+j] = ndp
        cnt[(1<<i)+j] = v

ans = [0]*M
ans[0] = 1
for mask in range(M):
    for i in range(m):
        if mask>>i&1: continue
        nmask = mask|(1<<i)
        if cnt[mask] <= 2*cnt[nmask]:
            ans[nmask] += ans[mask]
print(ans[-1])
0