結果
問題 |
No.2926 Botaoshi
|
ユーザー |
|
提出日時 | 2024-10-14 14:55:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 1,491 bytes |
コンパイル時間 | 2,827 ms |
コンパイル使用メモリ | 129,668 KB |
実行使用メモリ | 14,356 KB |
最終ジャッジ日時 | 2024-10-14 14:55:04 |
合計ジャッジ時間 | 3,370 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 |
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #ifdef local #include <C++/core/io/debug_print.hpp> #else #define dump(...) void(0); #endif #include <iostream> #include <ranges> #include <vector> #include <algorithm> #include <atcoder/modint> namespace man { using mint = atcoder::modint998244353; const std::string look = "LRU"; } int main() { std::cin.tie(nullptr) -> sync_with_stdio(false); using namespace std::views; int n; std::string s; std::cin >> n >> s; std::vector dp(n, std::vector(3, man::mint(0))); auto &init = dp.front(); const auto id = man::look.find(s.front()); dump(id); if(id == std::string::npos) { std::ranges::fill(init, man::mint(1)); } else { init[id] = man::mint(1); } for(const auto i: iota(0, n - 1)) { if(s[i + 1] == 'L') { dp[i + 1][0] = dp[i][0] + dp[i][2]; } else if(s[i + 1] == 'R') { dp[i + 1][1] = dp[i][0] + dp[i][1] + dp[i][2]; } else if(s[i + 1] == 'U') { dp[i + 1][2] = dp[i][0] + dp[i][1] + dp[i][2]; } else { dp[i + 1][0] = dp[i][0] + dp[i][2]; dp[i + 1][1] = dp[i][0] + dp[i][1] + dp[i][2]; dp[i + 1][2] = dp[i][0] + dp[i][1] + dp[i][2]; } } const auto &ret = dp.back(); std::cout << std::accumulate(ret.cbegin(), ret.cend(), man::mint(0)).val() << '\n'; }