結果

問題 No.2926 Botaoshi
ユーザー cyan515
提出日時 2024-11-17 19:39:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,435 bytes
コンパイル時間 5,203 ms
コンパイル使用メモリ 280,668 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2024-11-17 19:39:47
合計ジャッジ時間 8,259 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 3001001001001001001;
const int MOD = 998244353;
const string Yes = "Yes";
const string No = "No";
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> istream &operator>>(istream &is, vector<T> &v) {for (T &in : v)is >> in;return is;}
// #include <ext/pb_ds/assoc_container.hpp>
// template<typename T>
// using ordered_set = __gnu_pbds::tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
  int n;cin>>n;
  string s;cin>>s;
  vector dp(n+1,vector<mint>(3,0));
  dp.at(0).at(1) = 1;
  rep(i,n) {
    if(s.at(i)=='R'||s.at(i)=='.') {
      rep(j,3) dp.at(i+1).at(0) += dp.at(i).at(j);
    }
    if(s.at(i)=='U'||s.at(i)=='.') {
      rep(j,3) dp.at(i+1).at(1) += dp.at(i).at(j);
    }
    if(s.at(i)=='L'||s.at(i)=='.') {
      dp.at(i+1).at(2) += dp.at(i).at(1) + dp.at(i).at(2);
    }
  }
  mint ans = 0;
  rep(i,3) ans += dp.at(n).at(i);
  cout << ans.val() << endl;

  return 0;
}
0