結果

問題 No.2636 No Waiting in Vain
ユーザー hirayuu_ychirayuu_yc
提出日時 2024-02-18 14:03:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,026 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 226,736 KB
最終ジャッジ日時 2024-02-18 14:04:26
合計ジャッジ時間 45,910 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 977 ms
214,856 KB
testcase_01 AC 964 ms
214,856 KB
testcase_02 AC 990 ms
214,856 KB
testcase_03 AC 992 ms
214,856 KB
testcase_04 AC 1,012 ms
226,608 KB
testcase_05 AC 990 ms
226,608 KB
testcase_06 AC 978 ms
222,512 KB
testcase_07 AC 990 ms
226,736 KB
testcase_08 AC 978 ms
222,512 KB
testcase_09 AC 984 ms
226,604 KB
testcase_10 AC 982 ms
226,604 KB
testcase_11 AC 977 ms
220,440 KB
testcase_12 AC 985 ms
226,608 KB
testcase_13 AC 986 ms
226,736 KB
testcase_14 AC 1,002 ms
222,508 KB
testcase_15 AC 988 ms
226,736 KB
testcase_16 AC 980 ms
220,448 KB
testcase_17 AC 986 ms
226,736 KB
testcase_18 AC 980 ms
222,512 KB
testcase_19 AC 989 ms
226,608 KB
testcase_20 AC 987 ms
226,604 KB
testcase_21 AC 988 ms
226,608 KB
testcase_22 AC 1,006 ms
224,560 KB
testcase_23 AC 985 ms
226,604 KB
testcase_24 AC 989 ms
215,112 KB
testcase_25 AC 972 ms
215,112 KB
testcase_26 AC 967 ms
215,112 KB
testcase_27 AC 968 ms
215,112 KB
testcase_28 AC 976 ms
217,200 KB
testcase_29 AC 969 ms
215,112 KB
testcase_30 AC 968 ms
215,112 KB
testcase_31 AC 973 ms
215,112 KB
testcase_32 AC 971 ms
215,112 KB
testcase_33 AC 1,013 ms
215,112 KB
testcase_34 AC 995 ms
215,112 KB
testcase_35 AC 1,026 ms
215,240 KB
testcase_36 AC 1,019 ms
215,112 KB
testcase_37 AC 967 ms
215,112 KB
testcase_38 AC 992 ms
217,200 KB
testcase_39 AC 993 ms
215,112 KB
testcase_40 AC 994 ms
215,112 KB
testcase_41 AC 970 ms
217,328 KB
testcase_42 AC 994 ms
215,112 KB
testcase_43 AC 993 ms
215,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fact=[]
rev=[]
def comb_init(N=1000000,MOD=998244353):
    global fact,rev
    fact=[1]
    rev=[1]
    for i in range(N):
        fact.append((fact[-1]*(i+1))%MOD)
        rev.append((rev[-1]*pow(i+1,MOD-2,MOD))%MOD)

def comb(n,r,MOD=998244353):
    if n<r:
        return 0
    return (fact[n]*rev[r]*rev[n-r])%MOD

comb_init()
N,K=map(int,input().split())
S="P"+input()
cnt=0
for i in range(N):
	if S[i+1]=="N":
		if S[i]!="C":
			cnt+=1
		else:
			K-=1
ans=0
for i in range(1,cnt-K+1):
	ans+=comb(cnt,i)
print(ans%998244353)
0