結果
問題 | No.2636 No Waiting in Vain |
ユーザー | matcharate12 |
提出日時 | 2023-08-11 15:38:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 1,578 bytes |
コンパイル時間 | 1,445 ms |
コンパイル使用メモリ | 168,552 KB |
実行使用メモリ | 10,900 KB |
最終ジャッジ日時 | 2024-09-29 00:20:05 |
合計ジャッジ時間 | 3,353 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
10,692 KB |
testcase_01 | AC | 9 ms
10,536 KB |
testcase_02 | AC | 9 ms
10,672 KB |
testcase_03 | AC | 9 ms
10,572 KB |
testcase_04 | AC | 15 ms
10,900 KB |
testcase_05 | AC | 16 ms
10,736 KB |
testcase_06 | AC | 16 ms
10,888 KB |
testcase_07 | AC | 17 ms
10,764 KB |
testcase_08 | AC | 17 ms
10,884 KB |
testcase_09 | AC | 16 ms
10,864 KB |
testcase_10 | AC | 17 ms
10,760 KB |
testcase_11 | AC | 16 ms
10,784 KB |
testcase_12 | AC | 17 ms
10,884 KB |
testcase_13 | AC | 17 ms
10,888 KB |
testcase_14 | AC | 18 ms
10,760 KB |
testcase_15 | AC | 16 ms
10,884 KB |
testcase_16 | AC | 16 ms
10,788 KB |
testcase_17 | AC | 16 ms
10,760 KB |
testcase_18 | AC | 16 ms
10,872 KB |
testcase_19 | AC | 16 ms
10,760 KB |
testcase_20 | AC | 17 ms
10,760 KB |
testcase_21 | AC | 15 ms
10,804 KB |
testcase_22 | AC | 15 ms
10,884 KB |
testcase_23 | AC | 15 ms
10,888 KB |
testcase_24 | AC | 8 ms
10,560 KB |
testcase_25 | AC | 10 ms
10,580 KB |
testcase_26 | AC | 9 ms
10,576 KB |
testcase_27 | AC | 9 ms
10,704 KB |
testcase_28 | AC | 8 ms
10,520 KB |
testcase_29 | AC | 9 ms
10,700 KB |
testcase_30 | AC | 8 ms
10,576 KB |
testcase_31 | AC | 10 ms
10,580 KB |
testcase_32 | AC | 9 ms
10,576 KB |
testcase_33 | AC | 9 ms
10,576 KB |
testcase_34 | AC | 9 ms
10,580 KB |
testcase_35 | AC | 9 ms
10,576 KB |
testcase_36 | AC | 9 ms
10,576 KB |
testcase_37 | AC | 9 ms
10,580 KB |
testcase_38 | AC | 9 ms
10,580 KB |
testcase_39 | AC | 9 ms
10,708 KB |
testcase_40 | AC | 9 ms
10,576 KB |
testcase_41 | AC | 8 ms
10,708 KB |
testcase_42 | AC | 9 ms
10,648 KB |
testcase_43 | AC | 10 ms
10,704 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) //[0,n) #define srep(i,a,b) for(int 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(A) using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<ll,ll>; using pq = priority_queue<ll,vector<ll>>; const ll inf = 8e18; const int iinf = (int)1e9; const int mod9 = 998244353; const int mod1 = 1000000007; struct Edge { int to; ll cost; int from; }; bool compe(const Edge &e,const Edge &e2){ return e.cost < e2.cost; } using Graph = vector<vector<int>>; using EGraph = vector<Edge>; using SGraph = vector<set<ll>>; template <typename T> int siz(T& a){ return (int)a.size(); } double squa(double x){ return 1.0*x*x; } double pi = acos(-1); using namespace std; ll const MAX = 303030; ll const MOD = mod9; ll fac[MAX],finv[MAX],inv[MAX]; void Cinit(){ 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){ if(n < k || (n < 0 || k < 0)) return 0; return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD; } int main(){ int n,k; cin >> n >> k; string s; cin >> s; int cnt = 0,ncnt = 0; rep(i,n){ if(i+1 < n && s[i] == 'C' && s[i+1] == 'N') cnt++; if(s[i] == 'N') ncnt++; } k -= cnt; ncnt -= cnt; Cinit(); ll ans = 0; srep(i,k,ncnt) (ans += nCr(ncnt,i)) %= mod9; cout << ans << endl; }