結果

問題 No.2388 At Least K-Characters
ユーザー 👑 timitimi
提出日時 2024-02-16 19:17:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,352 KB
最終ジャッジ日時 2024-02-16 19:17:43
合計ジャッジ時間 18,705 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 48 ms
64,100 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 37 ms
53,460 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 38 ms
53,460 KB
testcase_12 WA -
testcase_13 AC 63 ms
74,156 KB
testcase_14 AC 71 ms
76,204 KB
testcase_15 AC 77 ms
76,232 KB
testcase_16 AC 686 ms
76,980 KB
testcase_17 AC 717 ms
76,956 KB
testcase_18 AC 652 ms
76,984 KB
testcase_19 AC 717 ms
77,300 KB
testcase_20 AC 731 ms
76,980 KB
testcase_21 AC 776 ms
76,984 KB
testcase_22 AC 751 ms
76,980 KB
testcase_23 AC 774 ms
76,980 KB
testcase_24 AC 764 ms
76,980 KB
testcase_25 AC 680 ms
76,984 KB
testcase_26 AC 741 ms
76,980 KB
testcase_27 AC 710 ms
76,984 KB
testcase_28 AC 761 ms
76,980 KB
testcase_29 AC 752 ms
76,980 KB
testcase_30 AC 688 ms
76,980 KB
testcase_31 AC 702 ms
76,984 KB
testcase_32 AC 682 ms
76,992 KB
testcase_33 AC 700 ms
76,984 KB
testcase_34 AC 735 ms
76,980 KB
testcase_35 AC 809 ms
77,004 KB
testcase_36 AC 720 ms
77,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K=map(int, input().split())
S=input()
dp=[[0]*2 for i in range(28)]
dp[0][0]=1;T=[0]*26 

ans=0;mod=998244353
for j in range(N):
  ss=S[j]
  ndp=[[0]*2 for _ in range(28)]
  s=ord(ss)-ord('a')
  for i in range(27):
    ndp[i][1]+=dp[i][1]*i
    ndp[i][1]%=mod
    ndp[i+1][1]+=dp[i][1]*(26-i)
    ndp[i+1][1]%=mod
  t=sum(T)
  for i in range(s):
    if T[i]==0:
      ndp[t+1][1]+=dp[t][0]
      ndp[t+1][1]%=mod
    else:
      ndp[t][1]+=dp[t][0]
      ndp[t][1]%=mod
  if T[s]==0:
    ndp[t+1][0]+=dp[t][0]
    ndp[t+1][0]%=mod
  else:
    ndp[t][0]+=dp[t][0]
    ndp[t][0]%=mod
  T[s]=1
  dp=ndp
  for i in range(K,27):
    ans+=dp[i][0]
    ans+=dp[i][1]
    ans%=mod

for _ in range(M-N):
  ndp=[[0]*2 for _ in range(28)]
  for i in range(27):
    ndp[i][1]+=dp[i][1]*i
    ndp[i][1]%=mod
    ndp[i+1][1]+=dp[i][1]*(26-i)
    ndp[i+1][1]%=mod
  dp=ndp 
  for i in range(K,27):
    ans+=dp[i][0]
    ans+=dp[i][1]
    ans%=mod

print((ans-1)%mod)
0