結果
問題 |
No.1740 Alone 'a'
|
ユーザー |
![]() |
提出日時 | 2021-11-12 22:09:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,020 KB |
実行使用メモリ | 78,380 KB |
最終ジャッジ日時 | 2024-11-25 18:56:42 |
合計ジャッジ時間 | 5,767 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
mod = 998244353 n = int(input()) S = [ord(s)-ord("a") for s in input()] dp = [[0]*2 for _ in range(2)] dp[0][0] = 1 for s in S: ndp = [[0]*2 for _ in range(2)] for j0 in range(2): for k0 in range(2): for j1 in range(2): for k1 in range(2): if j0 > j1 or k0 > k1: continue if k0 < k1: if not (j0 or (j1 ^ (s == 0))): continue c = 1 else: if (j0,j1) == (0,0): c = s > 0 elif (j0,j1) == (0,1): c = max(s-1,0) else: c = 25 ndp[j1][k1] += dp[j0][k0]*c ndp[j1][k1] %= mod dp = ndp print(dp[1][1])