結果

問題 No.2926 Botaoshi
ユーザー yel_ow
提出日時 2024-11-24 04:17:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 5,574 ms
コンパイル使用メモリ 311,792 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2024-11-24 04:17:11
合計ジャッジ時間 7,893 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <monsterenergy>
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;

int main()
{
    int N; cin >> N;
    string S; cin >> S;
    vector<vector<mint>> DP(N+1,vector<mint>(4));
    DP[0][0] = 1;
    for(int i = 0; i < N; i++)
    {
        if(S[i] == 'L' || S[i] == '.') DP[i+1][1] = DP[i][0]+DP[i][1]+DP[i][3];
        if(S[i] == 'R' || S[i] == '.') DP[i+1][2] = DP[i][0]+DP[i][1]+DP[i][2]+DP[i][3];
        if(S[i] == 'U' || S[i] == '.') DP[i+1][3] = DP[i][0]+DP[i][1]+DP[i][2]+DP[i][3];
    }
    cout << (DP[N][1]+DP[N][2]+DP[N][3]).val() << endl;
    return 0;
}
0