結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
12,792 KB
testcase_01 AC 141 ms
12,908 KB
testcase_02 AC 141 ms
12,868 KB
testcase_03 AC 122 ms
12,880 KB
testcase_04 AC 119 ms
12,820 KB
testcase_05 AC 130 ms
12,808 KB
testcase_06 AC 141 ms
12,840 KB
testcase_07 AC 125 ms
12,864 KB
testcase_08 AC 112 ms
12,820 KB
testcase_09 AC 113 ms
12,936 KB
testcase_10 AC 110 ms
13,084 KB
testcase_11 AC 110 ms
12,868 KB
testcase_12 AC 140 ms
12,876 KB
testcase_13 AC 135 ms
12,792 KB
testcase_14 AC 123 ms
12,812 KB
testcase_15 AC 112 ms
12,868 KB
testcase_16 AC 107 ms
13,068 KB
testcase_17 AC 110 ms
12,932 KB
testcase_18 AC 116 ms
12,812 KB
testcase_19 AC 130 ms
12,848 KB
testcase_20 AC 130 ms
12,848 KB
testcase_21 AC 103 ms
12,772 KB
testcase_22 AC 104 ms
12,768 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(i,1024){
        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)){
            sum+=dp[j][i]*comb(cnt[0],k-j)%mod;
            sum%=mod;
        }
    }
    sum*=kji[k];
    cout<<sum%mod<<endl;
}
0