結果

問題 No.1189 Sum is XOR
ユーザー ktr216ktr216
提出日時 2020-08-22 15:13:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 1,724 ms
コンパイル使用メモリ 171,988 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 09:36:43
合計ジャッジ時間 3,495 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 22 ms
5,376 KB
testcase_04 AC 19 ms
5,376 KB
testcase_05 AC 31 ms
5,376 KB
testcase_06 AC 45 ms
5,376 KB
testcase_07 AC 26 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 10 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 21 ms
5,376 KB
testcase_22 AC 21 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N), B(1024, 0);
    rep(i, N) {
        cin >> A[i];
        B[A[i]]++;
    }
    if (K > 10) {
        cout << "0\n";
        return 0;
    }
    vector<vector<vector<ll>>> dp(1024, vector<vector<ll>>(11, vector<ll>(2, 0)));
    dp[0][0][0] = 1;
    ll MOD = 998244353;
    rep(i, 1024) {
        rep(j, 10) {
            rep(k, 1024) {
                if (i & k) continue;
                dp[i ^ k][j + 1][(k + 1) % 2] += dp[i][j][k % 2] * B[k];
                dp[i ^ k][j + 1][(k + 1) % 2] %= MOD;
            }
        }
    }
    ll ans = 0;
    rep(i, 1024) {
        ans = (ans + dp[i][K][0]) % MOD;
    }
    cout << ans << "\n";
}
0