結果

問題 No.1189 Sum is XOR
ユーザー trineutrontrineutron
提出日時 2020-08-22 15:20:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 920 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 203,812 KB
実行使用メモリ 818,304 KB
最終ジャッジ日時 2024-04-23 09:41:10
合計ジャッジ時間 5,462 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int64_t mod = 998244353;

int main() {
    int n, k;
    cin >> n >> k;
    if (k > 10) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    
    vector dp(n + 1, vector(1024, vector(k + 1, 0L)));
    dp.at(0).at(0).at(0) = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 1024; j++) {
            for (int l = 0; l <= k; l++) {
                (dp.at(i + 1).at(j).at(l) += dp.at(i).at(j).at(l)) %= mod;
            }
            if (a.at(i) & j) continue;
            for (int l = 0; l < k; l++) {
                (dp.at(i + 1).at(a.at(i) | j).at(l + 1) += dp.at(i).at(j).at(l)) %= mod;
            }
        }
    }
    
    int64_t ans = 0;
    for (int i = 0; i < 1024; i++) {
        ans += dp.at(n).at(i).at(k);
    }
    cout << ans % mod << endl;
}
0