結果

問題 No.1189 Sum is XOR
ユーザー tamatotamato
提出日時 2020-08-24 20:05:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 102,528 KB
最終ジャッジ日時 2024-04-24 03:46:03
合計ジャッジ時間 3,459 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
102,528 KB
testcase_01 AC 126 ms
102,400 KB
testcase_02 AC 116 ms
102,016 KB
testcase_03 AC 57 ms
77,440 KB
testcase_04 AC 55 ms
74,752 KB
testcase_05 AC 66 ms
85,760 KB
testcase_06 AC 77 ms
97,664 KB
testcase_07 AC 60 ms
79,744 KB
testcase_08 AC 48 ms
66,560 KB
testcase_09 AC 49 ms
67,584 KB
testcase_10 AC 46 ms
64,896 KB
testcase_11 AC 104 ms
70,656 KB
testcase_12 AC 114 ms
101,760 KB
testcase_13 AC 152 ms
97,664 KB
testcase_14 AC 134 ms
84,736 KB
testcase_15 AC 133 ms
70,400 KB
testcase_16 AC 153 ms
67,200 KB
testcase_17 AC 114 ms
69,504 KB
testcase_18 AC 99 ms
75,904 KB
testcase_19 AC 140 ms
90,624 KB
testcase_20 AC 163 ms
91,008 KB
testcase_21 AC 66 ms
61,568 KB
testcase_22 AC 65 ms
61,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


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

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    if K > 10:
        print(0)
        exit()

    cnt = [0] * 1024
    for a in A:
        cnt[a] += 1
    dp = [[0] * 1024 for _ in range(K+1)]
    dp[0][0] = 1
    for new in range(1, 1024):
        for k in range(K):
            for state in range(1024):
                if state & new == 0:
                    dp[k+1][state | new] = (dp[k+1][state | new] + dp[k][state] * cnt[new])%mod
    ans = 0
    for x in dp[K]:
        ans = (ans + x)%mod
    print(ans)


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