結果

問題 No.2926 Botaoshi
ユーザー prd_xxx
提出日時 2024-10-12 15:29:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,072 KB
実行使用メモリ 76,996 KB
最終ジャッジ日時 2024-10-12 15:29:07
合計ジャッジ時間 5,194 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
MOD = 998244353

dp = [1,0,0]
for c in S:
    ndp = [0,0,0]
    if c == 'L':
        ndp[0] = sum(dp[:2]) % MOD
    elif c == 'U':
        ndp[1] = sum(dp) % MOD
    elif c == 'R':
        ndp[2] = sum(dp) % MOD
    else:
        ndp[0] = sum(dp[:2]) % MOD
        ndp[1] = sum(dp) % MOD
        ndp[2] = sum(dp) % MOD
    dp = ndp
print(sum(dp) % MOD)
0