結果

問題 No.1560 majority x majority
ユーザー ああいいああいい
提出日時 2022-05-31 09:32:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 776 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 162,260 KB
最終ジャッジ日時 2023-10-21 00:32:26
合計ジャッジ時間 8,671 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 35 ms
53,568 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 AC 316 ms
76,280 KB
testcase_07 AC 126 ms
76,880 KB
testcase_08 AC 1,138 ms
81,424 KB
testcase_09 AC 555 ms
76,504 KB
testcase_10 AC 63 ms
70,976 KB
testcase_11 AC 134 ms
76,792 KB
testcase_12 AC 91 ms
76,492 KB
testcase_13 AC 147 ms
76,260 KB
testcase_14 AC 92 ms
76,844 KB
testcase_15 AC 401 ms
76,332 KB
testcase_16 AC 85 ms
76,668 KB
testcase_17 AC 1,168 ms
81,400 KB
testcase_18 AC 269 ms
77,476 KB
testcase_19 AC 63 ms
70,976 KB
testcase_20 AC 86 ms
76,672 KB
testcase_21 AC 84 ms
76,876 KB
testcase_22 AC 470 ms
77,960 KB
testcase_23 AC 64 ms
73,024 KB
testcase_24 AC 85 ms
76,572 KB
testcase_25 AC 407 ms
77,624 KB
testcase_26 AC 35 ms
53,568 KB
testcase_27 AC 34 ms
53,568 KB
testcase_28 AC 35 ms
53,568 KB
testcase_29 AC 41 ms
59,668 KB
testcase_30 AC 92 ms
162,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(N)]
dp = [0] * (1 << M)

def calc(mask):
    l = [0] * N
    count = 0
    for i in range(N):
        tmp = 1
        for j in range(M):
            if (mask >> j) & 1 == 0:continue
            tmp &= S[i][j]
        l[i] = tmp
        count += tmp
    return (l,count)
for i in range(M):
    mask = 1 << i
    l,count = calc(mask)
    if count >= (N+1) // 2:
        dp[mask] = 1
for bit in range(1,1 << M):
    l,count = calc(bit)
    for i in range(M):
        mask = 1 << i
        if mask & bit:continue
        num = 0
        for j in range(N):
            num += l[j] & S[j][i]
        if num >= (count + 1) // 2:
            dp[bit | mask] += dp[bit]
        
print(dp[-1])
#print(dp)
0