結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
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 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 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>10)
    {
        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];
                    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