結果

問題 No.1189 Sum is XOR
ユーザー pockynypockyny
提出日時 2020-08-22 16:45:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 71,600 KB
実行使用メモリ 97,920 KB
最終ジャッジ日時 2024-04-23 10:51:43
合計ジャッジ時間 4,753 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 222 ms
97,920 KB
testcase_01 AC 182 ms
97,792 KB
testcase_02 AC 167 ms
97,664 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 160 ms
97,664 KB
testcase_12 AC 176 ms
97,920 KB
testcase_13 AC 220 ms
97,792 KB
testcase_14 AC 189 ms
97,664 KB
testcase_15 AC 192 ms
97,664 KB
testcase_16 AC 211 ms
97,792 KB
testcase_17 AC 172 ms
97,664 KB
testcase_18 AC 156 ms
97,664 KB
testcase_19 AC 199 ms
97,664 KB
testcase_20 AC 223 ms
97,792 KB
testcase_21 AC 127 ms
97,792 KB
testcase_22 AC 120 ms
97,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
typedef long long ll;
ll cnt[2000] = {},dp[1100][1100][11],mod = 998244353;
int main(){
    int i,j,l,n,k; cin >> n >> k;
    if(k>10){
        cout << 0 << endl;
        return 0;
    }
    for(i=0;i<n;i++){
        int a; cin >> a; cnt[a]++;
    }
    dp[0][0][0] = 1;
    for(i=0;i<1024;i++){
        for(j=0;j<1024;j++){
            for(l=0;l<=k;l++){
                (dp[i + 1][j][l] += dp[i][j][l]) %= mod;
                if((i & j)==0) (dp[(i + 1)][(i|j)][l + 1] += cnt[i]*dp[i][j][l]) %= mod;
            }
        }
    }
    ll ans = 0;
    for(i=0;i<1024;i++){
        (ans += dp[1024][i][k]) %= mod;
    }
    cout << ans << endl;
}
0