結果
| 問題 | No.2926 Botaoshi | 
| コンテスト | |
| ユーザー |  umezo | 
| 提出日時 | 2024-10-12 15:41:24 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 10 ms / 2,000 ms | 
| コード長 | 935 bytes | 
| コンパイル時間 | 2,669 ms | 
| コンパイル使用メモリ | 244,972 KB | 
| 実行使用メモリ | 8,448 KB | 
| 最終ジャッジ日時 | 2024-10-12 15:41:32 | 
| 合計ジャッジ時間 | 4,142 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 42 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
const int MOD=998244353;
ll dp[200200][3];
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  string s;
  cin>>n>>s;
  dp[0][1]=1;
  rep(i,n){
    if(s[i]=='L'){
      dp[i+1][2]=(dp[i+1][2]+dp[i][1]+dp[i][2])%MOD;
    }
    else if(s[i]=='U'){
      dp[i+1][1]=(dp[i+1][1]+dp[i][0]+dp[i][1]+dp[i][2])%MOD;
    }
    else if(s[i]=='R'){
      dp[i+1][0]=(dp[i+1][0]+dp[i][0]+dp[i][1]+dp[i][2])%MOD;
    }
    else{
      dp[i+1][0]=(dp[i+1][0]+dp[i][0]+dp[i][1]+dp[i][2])%MOD;
      dp[i+1][1]=(dp[i+1][1]+dp[i][0]+dp[i][1]+dp[i][2])%MOD;
      dp[i+1][2]=(dp[i+1][2]+dp[i][1]+dp[i][2])%MOD;
    }
  }
  ll ans=0;
  rep(i,3) ans=(ans+dp[n][i])%MOD;
  cout<<ans<<endl;
  return 0;
}
            
            
            
        