結果

問題 No.2636 No Waiting in Vain
ユーザー umezoumezo
提出日時 2024-02-18 19:45:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 202,672 KB
実行使用メモリ 17,908 KB
最終ジャッジ日時 2024-02-18 19:45:38
合計ジャッジ時間 4,556 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
17,524 KB
testcase_01 AC 12 ms
17,524 KB
testcase_02 AC 12 ms
17,524 KB
testcase_03 AC 12 ms
17,524 KB
testcase_04 AC 16 ms
17,908 KB
testcase_05 AC 17 ms
17,908 KB
testcase_06 AC 16 ms
17,908 KB
testcase_07 AC 16 ms
17,908 KB
testcase_08 AC 15 ms
17,908 KB
testcase_09 AC 16 ms
17,908 KB
testcase_10 AC 17 ms
17,908 KB
testcase_11 AC 17 ms
17,908 KB
testcase_12 AC 17 ms
17,908 KB
testcase_13 AC 17 ms
17,908 KB
testcase_14 AC 17 ms
17,908 KB
testcase_15 AC 16 ms
17,908 KB
testcase_16 AC 15 ms
17,908 KB
testcase_17 AC 15 ms
17,908 KB
testcase_18 AC 15 ms
17,908 KB
testcase_19 AC 17 ms
17,908 KB
testcase_20 AC 18 ms
17,908 KB
testcase_21 AC 17 ms
17,908 KB
testcase_22 AC 16 ms
17,908 KB
testcase_23 AC 16 ms
17,908 KB
testcase_24 AC 13 ms
17,524 KB
testcase_25 AC 13 ms
17,524 KB
testcase_26 AC 13 ms
17,524 KB
testcase_27 AC 14 ms
17,524 KB
testcase_28 AC 13 ms
17,524 KB
testcase_29 AC 14 ms
17,524 KB
testcase_30 AC 12 ms
17,524 KB
testcase_31 AC 12 ms
17,524 KB
testcase_32 AC 12 ms
17,524 KB
testcase_33 AC 16 ms
17,524 KB
testcase_34 AC 13 ms
17,524 KB
testcase_35 AC 13 ms
17,524 KB
testcase_36 AC 14 ms
17,524 KB
testcase_37 AC 13 ms
17,524 KB
testcase_38 AC 16 ms
17,524 KB
testcase_39 AC 12 ms
17,524 KB
testcase_40 AC 11 ms
17,524 KB
testcase_41 AC 12 ms
17,524 KB
testcase_42 AC 13 ms
17,524 KB
testcase_43 AC 13 ms
17,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int MAX=600600;
const int MOD=998244353;
ll fac[MAX],finv[MAX],inv[MAX];

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll nCr(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  init();
  ll n,k;
  string s;
  cin>>n>>k>>s;
  ll a=0,b=0;
  rep(i,n){
    if(s[i]=='N'){
      a++;
      if(i && s[i-1]!='C') b++;
      if(i==0) b++;
    }
  }
  ll ans=0;
  for(int i=1;i<=max(0ll,a-k);i++){
    ans=(ans+nCr(b,i))%MOD;
  }
  cout<<ans<<endl;
  
  return 0;
}
0