結果
| 問題 |
No.1740 Alone 'a'
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2021-11-12 22:16:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,151 bytes |
| コンパイル時間 | 233 ms |
| コンパイル使用メモリ | 82,320 KB |
| 実行使用メモリ | 87,088 KB |
| 最終ジャッジ日時 | 2024-11-25 19:13:27 |
| 合計ジャッジ時間 | 11,552 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 28 |
ソースコード
"""
dp[i][密着][aがあるか] = ?
"""
import sys
from sys import stdin
N = int(stdin.readline())
SI = list(stdin.readline()[:-1])
S = [ord(c)-ord("a") for c in SI]
#print (S)
mod = 998244353
dp = [[0,0],[0,0]]
dp[1][0] = 1
for i in range(N):
ndp = [[0,0],[0,0]]
for c in range(26):
for linka in range(2):
for isa in range(2):
if linka == 1 and S[i] < c:
continue
elif isa == 1 and c == 0:
continue
if c == 0:
if S[i] == 0:
ndp[1][1] += dp[linka][isa]
else:
ndp[0][1] += dp[linka][isa]
elif linka == 1:
if S[i] == c:
ndp[1][isa] += dp[linka][isa]
else:
ndp[0][isa] += dp[linka][isa]
else:
ndp[linka][isa] += dp[linka][isa]
for x in range(2):
for y in range(2):
ndp[x][y] %= mod
dp = ndp
#print (dp)
#print (dp)
print (dp[0][1] % mod)
SPD_9X2