結果
問題 |
No.2926 Botaoshi
|
ユーザー |
![]() |
提出日時 | 2024-10-14 19:51:54 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 1,046 bytes |
コンパイル時間 | 2,719 ms |
コンパイル使用メモリ | 246,548 KB |
実行使用メモリ | 6,144 KB |
最終ジャッジ日時 | 2024-10-14 19:51:59 |
合計ジャッジ時間 | 4,115 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<VL> VVL; typedef long long LL; #define all(a) (a).begin(), (a).end() #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define ALL(a) (a).begin(),(a).end() #define pb push_back #include <atcoder/modint> using mint = atcoder::modint998244353; int main() { int n;cin>>n; string s;cin>>s; mint L[n]={},R[n]={},U[n]={}; if(s[0]=='L'){L[0]=1;} else if(s[0]=='R'){R[0]=1;} else if(s[0]=='U'){U[0]=1;} else{L[0]=1;R[0]=1;U[0]=1;} rep(i,n-1){ if(s[i+1]=='L'){ L[i+1]=L[i]+U[i]; } else if(s[i+1]=='R'){ R[i+1]=L[i]+R[i]+U[i]; } else if(s[i+1]=='U'){ U[i+1]=L[i]+R[i]+U[i]; } else{ L[i+1]=L[i]+U[i]; R[i+1]=L[i]+R[i]+U[i]; U[i+1]=L[i]+R[i]+U[i]; } } mint ans=0; ans+=L[n-1]+R[n-1]+U[n-1]; cout<<ans.val()<<endl; }