結果

問題 No.2926 Botaoshi
ユーザー timi
提出日時 2024-10-12 16:11:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,132 KB
実行使用メモリ 76,760 KB
最終ジャッジ日時 2024-10-12 16:11:35
合計ジャッジ時間 4,696 ms
ジャッジサーバーID
(参考情報)
judge3 / judge
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
from collections import deque

dp=[0,1,0]
mod=998244353
for s in S:
  ndp=[0,0,0]
  if s=='U':
    ndp[1]=sum(dp) 
  elif s=='L':
    ndp[2]=dp[1]+dp[2]
  elif s=='R':
    ndp[0]=sum(dp)
  else:
    ndp[0]=sum(dp)
    ndp[1]=sum(dp) 
    ndp[2]=dp[1]+dp[2] 
  dp=[]
  for c in ndp:
    dp.append(c%mod)
    
print(sum(dp)%mod)
0