結果
問題 | No.2636 No Waiting in Vain |
ユーザー | matcharate12 |
提出日時 | 2024-02-13 17:38:17 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 1,544 bytes |
コンパイル時間 | 1,717 ms |
コンパイル使用メモリ | 168,896 KB |
実行使用メモリ | 27,652 KB |
最終ジャッジ日時 | 2024-09-29 00:21:40 |
合計ジャッジ時間 | 6,830 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 88 ms
27,244 KB |
testcase_01 | AC | 83 ms
27,076 KB |
testcase_02 | AC | 83 ms
26,964 KB |
testcase_03 | AC | 83 ms
27,196 KB |
testcase_04 | AC | 89 ms
27,500 KB |
testcase_05 | AC | 99 ms
27,536 KB |
testcase_06 | AC | 86 ms
27,524 KB |
testcase_07 | AC | 91 ms
27,596 KB |
testcase_08 | AC | 96 ms
27,544 KB |
testcase_09 | AC | 94 ms
27,508 KB |
testcase_10 | AC | 103 ms
27,532 KB |
testcase_11 | AC | 96 ms
27,488 KB |
testcase_12 | AC | 100 ms
27,436 KB |
testcase_13 | AC | 96 ms
27,496 KB |
testcase_14 | AC | 101 ms
27,532 KB |
testcase_15 | AC | 98 ms
27,652 KB |
testcase_16 | AC | 92 ms
27,588 KB |
testcase_17 | AC | 100 ms
27,452 KB |
testcase_18 | AC | 96 ms
27,460 KB |
testcase_19 | AC | 101 ms
27,508 KB |
testcase_20 | AC | 94 ms
27,456 KB |
testcase_21 | AC | 98 ms
27,448 KB |
testcase_22 | AC | 94 ms
27,572 KB |
testcase_23 | AC | 99 ms
27,572 KB |
testcase_24 | AC | 82 ms
27,096 KB |
testcase_25 | AC | 92 ms
27,088 KB |
testcase_26 | AC | 79 ms
27,100 KB |
testcase_27 | AC | 83 ms
27,100 KB |
testcase_28 | AC | 90 ms
27,204 KB |
testcase_29 | AC | 86 ms
27,144 KB |
testcase_30 | AC | 89 ms
27,164 KB |
testcase_31 | AC | 86 ms
27,104 KB |
testcase_32 | AC | 87 ms
27,040 KB |
testcase_33 | AC | 92 ms
27,020 KB |
testcase_34 | AC | 86 ms
27,088 KB |
testcase_35 | AC | 88 ms
27,168 KB |
testcase_36 | AC | 81 ms
27,220 KB |
testcase_37 | AC | 87 ms
26,988 KB |
testcase_38 | AC | 87 ms
27,016 KB |
testcase_39 | AC | 81 ms
27,124 KB |
testcase_40 | AC | 88 ms
27,100 KB |
testcase_41 | AC | 90 ms
27,132 KB |
testcase_42 | AC | 87 ms
27,144 KB |
testcase_43 | AC | 82 ms
27,132 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(ll i = 0; i < n; i++) //[0,n) #define srep(i,a,b) for(ll i = a; i < b; i++) //[a,b) //#define all(A) (A).begin(),(A).end() //#define rall(A) (A).rbegin(),(A).rend() //#define pmt(A) next_permutation(all(A)) using namespace std; using ll = long long; //using ull = unsigned long long; //using P = pair<ll,ll>; //using pq = priority_queue<P,vector<P>,greater<P>>; ll inf = 1LL<<60; //int iinf = (int)1e9+1; int mod9 = 998244353; //int mod1 = 1000000007; //struct Edge { int to; int cost; int from; }; //bool compe(const Edge &e,const Edge &e2){ return e.cost < e2.cost; } //using Graph = vector<vector<ll>>; //using SGraph = vector<set<ll>>; //template <typename T> //int siz(T& a){return (int)a.size();} //ll squa(ll a){ return a*a; } //ll ceil(ll a,ll b){ return (a+b-1)/b; } ll const MAX = 1010101; ll fac[MAX],finv[MAX],inv[MAX]; void Cinit(ll mod){ fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; srep(i,2,MAX){ 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,ll mod){ if(n < k || (n < 0 || k < 0)) return 0; return fac[n]*(finv[k]*finv[n-k]%mod)%mod; } int main(void){ Cinit(mod9); int N,K; cin >> N >> K; string S; cin >> S; int d = 0; rep(i,N-1) if(S[i] == 'C' && S[i+1] == 'N') S[i+1] = 'I',d++; int c = 0; rep(i,N) if(S[i] == 'N') c++; if(c-K+d <= 0){ cout << 0; return 0; } ll ans = 0; rep(i,c-K+d) (ans += nCr(c,i+1,mod9)) %= mod9; cout << ans; }