結果

問題 No.2926 Botaoshi
ユーザー cled0328
提出日時 2024-10-12 15:40:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 195,412 KB
最終ジャッジ日時 2025-02-24 18:07:52
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    mint lf=1,rf=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            rf+=lf;
            lf=0;
        }else if(s[i]=='L'){
            rf=0;
        }else if(s[i]=='U'){
            lf+=rf;
            rf=0;
        }else{
            rf+=lf;
            lf+=rf;
        }
    }
    cout<<(lf+rf).val()<<"\n";
}
0