結果

問題 No.1689 Set Cards
ユーザー 👑 tamatotamato
提出日時 2021-09-24 21:31:46
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 87,492 KB
実行使用メモリ 77,668 KB
最終ジャッジ日時 2023-09-18 20:46:54
合計ジャッジ時間 4,262 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,992 KB
testcase_01 AC 75 ms
76,116 KB
testcase_02 AC 76 ms
76,048 KB
testcase_03 AC 79 ms
76,028 KB
testcase_04 AC 76 ms
75,924 KB
testcase_05 AC 77 ms
75,836 KB
testcase_06 AC 76 ms
75,996 KB
testcase_07 AC 77 ms
76,028 KB
testcase_08 AC 76 ms
76,152 KB
testcase_09 AC 75 ms
76,088 KB
testcase_10 AC 74 ms
75,992 KB
testcase_11 AC 101 ms
77,596 KB
testcase_12 AC 98 ms
77,636 KB
testcase_13 AC 103 ms
77,512 KB
testcase_14 AC 100 ms
77,464 KB
testcase_15 AC 81 ms
76,188 KB
testcase_16 AC 94 ms
77,640 KB
testcase_17 AC 78 ms
76,252 KB
testcase_18 AC 100 ms
77,560 KB
testcase_19 AC 99 ms
77,556 KB
testcase_20 AC 99 ms
77,668 KB
testcase_21 AC 95 ms
76,868 KB
testcase_22 AC 96 ms
77,004 KB
testcase_23 AC 96 ms
76,908 KB
testcase_24 AC 99 ms
77,652 KB
testcase_25 AC 100 ms
77,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    C = []
    for _ in range(N):
        line = list(map(int, input().split()))
        state = 0
        for c in line[1:]:
            state += 1 << (c - 1)
        C.append(state)

    dp = [0] * (1 << 12)
    dp[-1] = 1
    for c in C:
        dp_new = [0] * (1 << 12)
        for state in range(1 << 12):
            state_new = state & c
            dp_new[state] = (dp_new[state] + dp[state])%mod
            dp_new[state_new] = (dp_new[state_new] + dp[state])%mod
        dp = dp_new
    print(dp[0])


if __name__ == '__main__':
    main()
0