結果

問題 No.1560 majority x majority
ユーザー tcltktcltk
提出日時 2021-09-11 03:46:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 334 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 84,792 KB
最終ジャッジ日時 2023-09-04 00:36:54
合計ジャッジ時間 10,486 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 295 ms
84,764 KB
testcase_01 AC 334 ms
84,760 KB
testcase_02 AC 197 ms
81,024 KB
testcase_03 AC 270 ms
84,368 KB
testcase_04 AC 267 ms
84,716 KB
testcase_05 AC 328 ms
84,728 KB
testcase_06 AC 226 ms
84,276 KB
testcase_07 AC 225 ms
84,660 KB
testcase_08 AC 257 ms
84,512 KB
testcase_09 AC 232 ms
84,444 KB
testcase_10 AC 217 ms
84,412 KB
testcase_11 AC 230 ms
84,632 KB
testcase_12 AC 223 ms
84,464 KB
testcase_13 AC 233 ms
84,452 KB
testcase_14 AC 225 ms
84,548 KB
testcase_15 AC 232 ms
84,288 KB
testcase_16 AC 222 ms
84,684 KB
testcase_17 AC 292 ms
84,576 KB
testcase_18 AC 241 ms
84,792 KB
testcase_19 AC 215 ms
84,332 KB
testcase_20 AC 220 ms
84,320 KB
testcase_21 AC 220 ms
84,676 KB
testcase_22 AC 251 ms
84,620 KB
testcase_23 AC 217 ms
84,688 KB
testcase_24 AC 219 ms
84,680 KB
testcase_25 AC 248 ms
84,440 KB
testcase_26 AC 197 ms
80,884 KB
testcase_27 AC 197 ms
80,928 KB
testcase_28 AC 196 ms
81,104 KB
testcase_29 AC 198 ms
80,820 KB
testcase_30 AC 208 ms
84,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """6 3
# 1 1 1
# 1 0 1
# 0 0 1
# 1 0 1
# 0 1 0
# 1 1 0
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]

B = []
for i in range(N):
    b = 0
    for j in range(M):
        if S[i][j]:
            b |= (1<<j)
    B.append(b)

T = []
for mask in range(1<<M):
    n = 0
    for i in range(N):
        if mask & B[i] == mask:
            n += 1
    T.append(n)

dp = [0] * (1<<M)
dp[0] = 1
for mask in range(1<<M):
    for j in range(M):
        if mask & (1<<j):
            continue
        n_agree_before = T[mask]
        n_agree_after = T[mask | (1<<j)]
        if n_agree_after * 2 >= n_agree_before:
            dp[mask | (1<<j)] += dp[mask]

ans = dp[(1<<M)-1]
print(ans)
0