結果

問題 No.2926 Botaoshi
コンテスト
ユーザー tnodino
提出日時 2024-10-05 16:00:16
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 12 ms / 2,000 ms
+ 863µs
コード長 801 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,031 ms
コンパイル使用メモリ 188,704 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2026-09-11 03:31:05
合計ジャッジ時間 10,023 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use proconio::input;
use proconio::fastout;
use proconio::marker::Chars;
use ac_library::ModInt998244353 as Mint;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        S: Chars,
    }
    assert!(1 <= N && N <= 200_000 && N == S.len());
    assert!(S.iter().all(|x| ['.', 'L', 'R', 'U'].contains(x)));
    let mut DP = vec![vec![Mint::new(0); 3]; N+1];
    DP[0][0] = 1.into();
    for i in 0..N {
        if S[i] == 'U' || S[i] == '.' {
            DP[i+1][0] = DP[i][0] + DP[i][1] + DP[i][2];
        }
        if S[i] == 'L' || S[i] == '.' {
            DP[i+1][1] = DP[i][0] + DP[i][1];
        }
        if S[i] == 'R' || S[i] == '.' {
            DP[i+1][2] = DP[i][0] + DP[i][1] + DP[i][2];
        }
    }
    println!("{}", DP[N][0] + DP[N][1] + DP[N][2]);
}
0