結果

問題 No.1189 Sum is XOR
ユーザー auaua
提出日時 2020-08-22 15:51:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,413 bytes
コンパイル時間 1,612 ms
コンパイル使用メモリ 172,144 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-15 10:00:49
合計ジャッジ時間 3,492 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=998244353;
const int MAX=200010;


signed main(){
    ll n,k;cin>>n>>k;
    vector<ll>a(1024);
    rep(i,n){
        ll b;cin>>b;
        a[b]++;
    }
    n=1024;
    if(k>=11){
        cout<<0<<endl;
        return 0;
    }
    vector<vector<ll> >dp(k+1,vector<ll>(1024));
    vector<vector<ll> >dp1(k+1,vector<ll>(1024));
    dp[0][0]=1;
    rep(i,n){
        rep(j,k+1){
            rep(l,1024){
                dp1[j][l]=(dp1[j][l]+dp[j][l])%mod;
                if(j<k){
                    if(i+l==(i^l)){
                        dp1[j+1][l+i]=(dp1[j+1][l+i]+dp[j][l]*a[i]%mod)%mod;
                    }
                }
            }
        }
        rep(j,k+1){
            rep(l,1024){
                dp[j][l]=dp1[j][l];
                dp1[j][l]=0;
            }
        }
    }
    ll ans=0;
    rep(i,1024){
        ans=(ans+dp[k][i])%mod;
    }
    cout<<ans<<endl;
}
0