結果

問題 No.1189 Sum is XOR
ユーザー hiro71687khiro71687k
提出日時 2023-04-10 18:52:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,176 bytes
コンパイル時間 4,722 ms
コンパイル使用メモリ 255,748 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 22:45:13
合計ジャッジ時間 6,088 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144499999999994;
ll mod=998244353;
int main(){
    ll n,k;
    cin >> n >>  k;
    if (k>20)
    {
        cout  << 0 << endl;
        return 0;
    }
    vector<vector<ll>>dp(1024,vector<ll>(k+1,0));
    vector<ll>memo(1024,0);
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        memo[a]+=1;
    }
    dp[0][0]=1;
    for (ll i = 0; i < 1024; i++)
    {
        if (memo[i]==0)
        {
            continue;
        }
        for (ll j = k-1; j >=0; j--)
        {
            for (ll l = 0; l <1024; l++)
            {
                if (dp[l][j]==0)
                {
                    continue;
                }
                ll x=l;
                x^=i;
                if (x==l+i)
                {
                    dp[x][j+1]+=(dp[l][j]*memo[i])%mod;
                    dp[x][j+1]%=mod;
                }
            }
        }
    }
    ll ans=0;
    for (ll i = 0; i < 1024; i++)
    {
        ans+=dp[i][k];
        ans%=mod;
    }
    cout << ans << endl;
}
0