結果
問題 | No.2926 Botaoshi |
ユーザー | porkleoi |
提出日時 | 2024-10-12 15:15:47 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 5,721 bytes |
コンパイル時間 | 3,096 ms |
コンパイル使用メモリ | 250,660 KB |
実行使用メモリ | 14,476 KB |
最終ジャッジ日時 | 2024-10-12 15:15:53 |
合計ジャッジ時間 | 4,236 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | AC | 1 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 1 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,816 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 2 ms
6,820 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | AC | 21 ms
14,452 KB |
testcase_13 | AC | 20 ms
14,032 KB |
testcase_14 | AC | 19 ms
14,152 KB |
testcase_15 | AC | 2 ms
6,820 KB |
testcase_16 | AC | 16 ms
11,008 KB |
testcase_17 | AC | 18 ms
13,000 KB |
testcase_18 | AC | 5 ms
6,820 KB |
testcase_19 | AC | 13 ms
9,536 KB |
testcase_20 | AC | 7 ms
6,820 KB |
testcase_21 | AC | 12 ms
8,192 KB |
testcase_22 | AC | 13 ms
9,300 KB |
testcase_23 | AC | 4 ms
6,820 KB |
testcase_24 | AC | 14 ms
10,184 KB |
testcase_25 | AC | 5 ms
6,816 KB |
testcase_26 | AC | 17 ms
11,732 KB |
testcase_27 | AC | 12 ms
8,576 KB |
testcase_28 | AC | 4 ms
6,816 KB |
testcase_29 | AC | 3 ms
6,816 KB |
testcase_30 | AC | 7 ms
6,820 KB |
testcase_31 | AC | 5 ms
6,816 KB |
testcase_32 | AC | 10 ms
6,912 KB |
testcase_33 | AC | 16 ms
11,176 KB |
testcase_34 | AC | 15 ms
9,944 KB |
testcase_35 | AC | 2 ms
6,816 KB |
testcase_36 | AC | 21 ms
14,292 KB |
testcase_37 | AC | 21 ms
14,428 KB |
testcase_38 | AC | 20 ms
14,336 KB |
testcase_39 | AC | 21 ms
14,288 KB |
testcase_40 | AC | 19 ms
14,344 KB |
testcase_41 | AC | 21 ms
14,384 KB |
testcase_42 | AC | 21 ms
14,404 KB |
testcase_43 | AC | 20 ms
14,476 KB |
testcase_44 | AC | 21 ms
13,912 KB |
testcase_45 | AC | 21 ms
13,876 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = s; i <= (ll)(n); i++) #define rep3(i, s, n, d) for (ll i = s; i <= (ll)(n); i += d) #define rep4(i, s, n, d) for (ll i = s; i >= (ll)(n); i += d) typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<vvvi> vvvvi; typedef vector<string> vs; typedef vector<vs> vvs; typedef vector<vvs> vvvs; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vvc> vvvc; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<vvll> vvvll; typedef vector<vvvll> vvvvll; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<vvd> vvvd; typedef vector<ld> vld; typedef vector<vld> vvld; typedef vector<vvld> vvvld; typedef vector<bool> vb; typedef vector<vd> vvb; typedef vector<vvd> vvvb; typedef vector<pair<int, int>> vpi; typedef vector<pair<ll, ll>> vpll; typedef pair<int, int> pi; typedef vector<pi> vpi; typedef vector<vpi> vvpi; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef vector<vpll> vvpll; typedef tuple<int, int, int> tui3; typedef tuple<ll, ll, ll> tull3; typedef priority_queue<int, vector<int>, greater<int>> pqi; typedef priority_queue<vi, vector<vi>, greater<vi>> pqvi; typedef priority_queue<ll, vector<ll>, greater<ll>> pqll; typedef priority_queue<vll, vector<vll>, greater<vll>> pqvll; typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll; typedef priority_queue<pll, vector<pll>, less<pll>> rpqpll; typedef priority_queue<int, vector<int>, less<int>> rpqi; typedef priority_queue<vi, vector<vi>, less<vi>> rpqvi; typedef priority_queue<tui3, vector<tui3>, greater<tui3>> pqtui3; typedef priority_queue<tui3, vector<tui3>, less<tui3>> rpqtui3; typedef priority_queue<tull3, vector<tull3>, greater<tull3>> pqtull3; typedef priority_queue<tull3, vector<tull3>, less<tull3>> rpqtull3; #define yes(ans) if(ans)cout << "yes"<< endl; else cout << "no" << endl #define Yes(ans) if(ans)cout << "Yes"<< endl; else cout << "No" << endl #define YES(ans) if(ans)cout << "YES"<< endl ;else cout << "NO" << endl #define printv(vec) {rep(i, vec.size()) cout << vec[i] << ' '; cout << endl;} #define printvv(vec) rep(i, vec.size()) {rep(j, vec[i].size()) cout << vec[i][j] << ' '; cout << endl;}; #define printvvv(vec) rep(i, vec.size()) { rep(j, vec[i].size()) { rep(k, vec[i][j].size()) cout << vec[i][j][k] << ' '; cout << " "; }cout << endl; }; #define all1(x) x.begin(),x.end() #define all2(x) x.rbegin(), x.rend() #define so(x) sort(all1(x)) #define re(x) reverse(all1(x)) #define rso(x) sort(all2(x)) #define vco(x, a) count(all1(x), a) #define per(x) next_permutation(all1(x)) #define iINF 2147483647 #define llINF 9223372036854775807 #define INF 4000000000000000000 #define mod 998244353 #define mod2 1000000007 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<int MOD> struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator - () const noexcept { return val ? MOD - val : 0; } constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; } constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; } constexpr Fp& operator += (const Fp& r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp& operator -= (const Fp& r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp& operator *= (const Fp& r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp& operator /= (const Fp& r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator == (const Fp& r) const noexcept { return this->val == r.val; } constexpr bool operator != (const Fp& r) const noexcept { return this->val != r.val; } friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<mod>; typedef vector<mint> vm; typedef vector<vm> vvm; typedef vector<vvm> vvvm; typedef vector<vvvm> vvvvm; int main() { //アルゴリズム一覧を見る //嘘解法ですか int n; cin >> n; string s; cin >> s; vvm dp(n+1, vm(3)); dp[0][0] = 1; rep(i, n){ if(s[i]=='U') dp[i+1][0] = dp[i][0]+dp[i][1]+dp[i][2]; if(s[i]=='L') dp[i+1][1] = dp[i][0]+dp[i][1]; if(s[i]=='R') dp[i+1][2] = dp[i][0]+dp[i][1]+dp[i][2]; if(s[i]=='.'){ dp[i+1][0] += dp[i][0]+dp[i][1]+dp[i][2]; dp[i+1][1] = dp[i][0]+dp[i][1]; dp[i+1][2] = dp[i][0]+dp[i][1]+dp[i][2]; } } cout << dp[n][0]+dp[n][1]+dp[n][2] << endl; // printvv(dp); }