結果

問題 No.1189 Sum is XOR
ユーザー ShibuyapShibuyap
提出日時 2020-08-22 15:43:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,104 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 194,944 KB
実行使用メモリ 93,788 KB
最終ジャッジ日時 2024-04-23 10:00:28
合計ジャッジ時間 4,354 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
93,556 KB
testcase_01 AC 80 ms
93,756 KB
testcase_02 AC 81 ms
93,548 KB
testcase_03 AC 23 ms
6,940 KB
testcase_04 AC 19 ms
6,940 KB
testcase_05 AC 31 ms
6,944 KB
testcase_06 AC 46 ms
6,944 KB
testcase_07 AC 25 ms
6,940 KB
testcase_08 AC 12 ms
6,940 KB
testcase_09 AC 11 ms
6,944 KB
testcase_10 AC 9 ms
6,944 KB
testcase_11 AC 46 ms
93,668 KB
testcase_12 AC 80 ms
93,640 KB
testcase_13 AC 72 ms
93,788 KB
testcase_14 AC 60 ms
93,672 KB
testcase_15 AC 46 ms
93,676 KB
testcase_16 AC 42 ms
93,668 KB
testcase_17 AC 48 ms
93,672 KB
testcase_18 AC 53 ms
93,728 KB
testcase_19 AC 67 ms
93,760 KB
testcase_20 AC 71 ms
93,620 KB
testcase_21 AC 38 ms
93,604 KB
testcase_22 AC 38 ms
93,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
ll dp[1024][1024][11];
int main() {
    ll cnt[1024] = {};
    int n, K;
    cin >> n >> K;
    rep(i,n){
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll MOD = 998244353;

    if(K>10){
        cout << 0 << endl;
        return 0;
    }
    
    rep(i,1024)rep(j,1024)rep(k,11)dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    srep(i,1,1024){
        rep(j,1024)rep(k,11)dp[i][j][k] = dp[i-1][j][k];
        rep(j,1024){
            int x = i + j;
            int y = (i ^ j);
            if(x != y) continue;
            srep(k,1,11){
                dp[i][y][k] += dp[i-1][j][k-1] * cnt[i];
                dp[i][y][k] %= MOD;
            }
        }
    }
    ll ans = 0;
    rep(j,1024){
        ans += dp[1023][j][K];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


0