結果
問題 | No.1740 Alone 'a' |
ユーザー | titia |
提出日時 | 2021-11-12 22:41:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 302 ms / 2,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-11-25 20:19:25 |
合計ジャッジ時間 | 6,808 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import sys input = sys.stdin.readline N=int(input()) S=input().strip() mod=998244353 DP0=1 # 一致、a含まず DP1=0 # 一致、a含む DP2=0 # 一致せず、a含まず DP3=0 # 一致せず、a含む for s in S: NDP0=0 NDP1=0 NDP2=0 NDP3=0 if s=="a": NDP0=0 NDP1+=DP0 NDP2+=DP2*25 NDP3+=DP2+DP3*25 else: x=ord(s) NDP0+=DP0 NDP1+=DP1 NDP2+=DP0*(x-98)+DP2*25 NDP3+=DP0+DP1*(x-98)+DP2+DP3*25 DP0=NDP0%mod DP1=NDP1%mod DP2=NDP2%mod DP3=NDP3%mod #print(DP0,DP1,DP2,DP3) print((DP3)%mod)