結果

問題 No.1189 Sum is XOR
ユーザー RhoRho
提出日時 2020-08-02 00:44:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 1,298 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 166,296 KB
実行使用メモリ 13,148 KB
最終ジャッジ日時 2023-09-23 00:27:55
合計ジャッジ時間 5,605 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
12,864 KB
testcase_01 AC 142 ms
12,924 KB
testcase_02 AC 141 ms
12,820 KB
testcase_03 AC 122 ms
12,868 KB
testcase_04 AC 119 ms
12,872 KB
testcase_05 AC 130 ms
12,892 KB
testcase_06 AC 141 ms
12,880 KB
testcase_07 AC 123 ms
12,948 KB
testcase_08 AC 112 ms
12,948 KB
testcase_09 AC 111 ms
13,020 KB
testcase_10 AC 110 ms
13,148 KB
testcase_11 AC 111 ms
12,836 KB
testcase_12 AC 141 ms
12,808 KB
testcase_13 AC 135 ms
12,888 KB
testcase_14 AC 123 ms
13,144 KB
testcase_15 AC 110 ms
12,808 KB
testcase_16 AC 107 ms
12,796 KB
testcase_17 AC 110 ms
12,816 KB
testcase_18 AC 116 ms
12,816 KB
testcase_19 AC 129 ms
12,944 KB
testcase_20 AC 130 ms
12,804 KB
testcase_21 AC 102 ms
12,804 KB
testcase_22 AC 103 ms
13,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=998244353;
const long long inf=1ll<<61;
const int maxN=100;
int cnt[1111];
int cmb[1111];
int dp[12][1024];int kj[600006],kji[600006];
int modpow(int a,int x){
  int res=1;
  while(x){
    if(x&1)res=res*a%mod;
    a=a*a%mod;
    x>>=1;
  }
  return res;
}
void setkj(){
  kj[0]=kji[0]=1;
  for(int i=1;i<=600002;i++){
    kj[i]=kj[i-1]*i%mod;
    kji[i]=modpow(kj[i],mod-2);
  }
}
int comb(int r,int c){
  if(r<c)return 0;
  return kj[r]*kji[c]%mod*kji[r-c]%mod;
}
signed main(){
    setkj();
    int n,k;cin>>n>>k;
    rep(i,n){
        int a;cin>>a;cnt[a]++;
    }
    dp[0][0]=1;
    rep(j,11){
        rep(l,1<<10){
            if(!dp[j][l])continue;
            int m=1023-l;
            for(int t=m;;t=(t-1)&m){
                if(t==0)break;
                dp[j+1][t+l]+=dp[j][l]*cnt[t]%mod;
                dp[j+1][t+l]%=mod;
            }
        }
    }

    int sum=0;
    rep(i,1<<10){
        rep(j,min(k+1,11ll)){
            dp[j][i]*=kji[j];dp[j][i]%=mod;
            sum+=dp[j][i]*comb(cnt[0],k-j)%mod;
            sum%=mod;
        }
    }
    
    cout<<sum%mod<<endl;
}
0