結果
問題 | No.2926 Botaoshi |
ユーザー | yasunori |
提出日時 | 2024-10-12 16:33:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 6,981 bytes |
コンパイル時間 | 2,355 ms |
コンパイル使用メモリ | 208,548 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-10-12 16:33:30 |
合計ジャッジ時間 | 3,960 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 23 ms
14,336 KB |
testcase_13 | AC | 21 ms
14,020 KB |
testcase_14 | AC | 21 ms
14,064 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 15 ms
10,980 KB |
testcase_17 | AC | 18 ms
12,800 KB |
testcase_18 | AC | 5 ms
5,248 KB |
testcase_19 | AC | 13 ms
9,600 KB |
testcase_20 | AC | 6 ms
6,016 KB |
testcase_21 | AC | 11 ms
8,192 KB |
testcase_22 | AC | 14 ms
9,344 KB |
testcase_23 | AC | 3 ms
5,248 KB |
testcase_24 | AC | 15 ms
10,240 KB |
testcase_25 | AC | 5 ms
5,248 KB |
testcase_26 | AC | 18 ms
11,776 KB |
testcase_27 | AC | 11 ms
8,448 KB |
testcase_28 | AC | 4 ms
5,248 KB |
testcase_29 | AC | 3 ms
5,248 KB |
testcase_30 | AC | 7 ms
5,888 KB |
testcase_31 | AC | 5 ms
5,248 KB |
testcase_32 | AC | 8 ms
6,912 KB |
testcase_33 | AC | 15 ms
11,020 KB |
testcase_34 | AC | 14 ms
9,984 KB |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | AC | 23 ms
14,336 KB |
testcase_37 | AC | 22 ms
14,464 KB |
testcase_38 | AC | 21 ms
14,208 KB |
testcase_39 | AC | 21 ms
14,464 KB |
testcase_40 | AC | 21 ms
14,324 KB |
testcase_41 | AC | 20 ms
14,336 KB |
testcase_42 | AC | 20 ms
14,336 KB |
testcase_43 | AC | 20 ms
14,208 KB |
testcase_44 | AC | 19 ms
13,972 KB |
testcase_45 | AC | 18 ms
13,824 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; template <typename T> using min_priority_queue = priority_queue<T,vector<T>,greater<T>>; random_device seed_gen; mt19937 engine(seed_gen()); int64_t get_time(){ struct::timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * int64_t(1'000'000'000) + t.tv_nsec; } template<typename T> void invec(vector<T> &v){ for(auto &i : v) cin >> i; return; } template<typename T> void outvec(vector<T> &v, string s = " "){ bool b = false; for(auto i : v){ if(b) cout << s; else b = true; cout << i; } cout << endl; return; } template <typename T> bool chmin(T &a, const T& b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } template <typename T> bool chmax(T &a, const T& b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } template<typename T> T pow_mod(T a, T b, T n){ a %= n; if(a == 0) return 0; if(a == 1 || b == 0) return 1; if(b == 1) return a; T c = b/2; T d = b%2; T ac = pow_mod(a,c,n); T ad = pow_mod(a,d,n); return ac*ac%n*ad%n; } template <typename T> T ex_euclid(T a, T b, T &x, T &y){ T d = a; if(b != 0){ d = ex_euclid(b, a%b, y, x); y -= (a/b)*x; } else{ x = 1; y = 0; } //cout << a << " * " << x << " + " << b << " * " << y << " = " << d << endl; return d; } template <int64_t mod> struct modint{ int64_t val; modint(){ val = 0; } modint(int64_t a){ if(a <= -mod) a %= mod; else if(a >= mod) a %= mod; if(a < 0) a += mod; val = a; } modint inv(){ int64_t x, k; int64_t d = ex_euclid(val, mod, x, k); assert(d == 1); return modint(x); } bool operator==(modint other){ return val == other.val; } bool operator!=(modint other){ return val != other.val; } modint operator+(modint other){ return modint(val + other.val); } modint operator-(modint other){ return modint(val - other.val); } modint operator*(modint other){ return modint(val * other.val); } modint operator/(modint other){ return modint(val * other.inv().val); } void operator+=(modint other){ val += other.val; if(val >= mod) val -= mod; } void operator-=(modint other){ val -= other.val; if(val < 0) val += mod; } void operator*=(modint other){ val *= other.val; val %= mod; } void operator/=(modint other){ val *= other.inv().val; val %= mod; } void operator++(){ val++; if(val >= mod) val -= mod; } void operator--(){ val--; if(val < 0) val += mod; } }; template <int64_t mod> modint<mod> pow(modint<mod> a, int64_t b){ using mint = modint<mod>; if(b <= -(mod - 1)) b %= mod - 1; else if(b >= (mod - 1)) b %= mod - 1; if(b < 0) b += mod - 1; if(a == 0) return mint(0); if(b == 0) return mint(1); if(a == 1) return mint(1); if(b == 1) return a; mint x = pow(a, b / 2); mint y = pow(a, b % 2); return x * x * y; } template <int64_t mod> pair<vector<modint<mod>>, vector<modint<mod>>> init_mod_factorial(int N){ using mint = modint<mod>; vector<mint> v(N+1); vector<mint> v_inv(N+1); for(int i = 0; i <= N; i++){ if(i == 0) v[i] = 1; else v[i] = v[i - 1] * i; } for(int i = N; i >= 0; i--){ if(i == N) v_inv[i] = v[i].inv(); else v_inv[i] = v_inv[i+1] * (i + 1); } return make_pair(v, v_inv); } template <int64_t mod> modint<mod> factorial_mod(int64_t x, pair<vector<modint<mod>>, vector<modint<mod>>> &factorial_list){ return factorial_list.first[x]; } template <int64_t mod> modint<mod> factorial_inv_mod(int64_t x, pair<vector<modint<mod>>, vector<modint<mod>>> &factorial_list){ return factorial_list.second[x]; } template <int64_t mod> modint<mod> comb_mod(int64_t x, int64_t y, pair<vector<modint<mod>>, vector<modint<mod>>> &factorial_list){ if(y < 0 || x < y) return modint<mod>(0); return factorial_list.first[x] * factorial_list.second[y] * factorial_list.second[x - y]; } bool yn(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; return b; } bool check_with_simple_solution; bool calc_time; bool random_input; bool debug_output; int num_of_testcase; using ans_type = int; void input(){ if(num_of_testcase > 1){ } if(random_input){ } else{ } return; } void output_input(){ return; } void pre_solve(){ return; } ans_type solve(){ const int64_t mod = 998244353; using mint = modint<mod>; int n; cin >> n; string s; cin >> s; vector DP(n+1, vector<mint>(3, 0)); DP[0][0] = 1; for(int i = 0; i < n; i++) { char c = s[i]; if(c == 'L' || c == '.') { DP[i+1][0] += DP[i][0] + DP[i][1]; } if(c == 'U' || c == '.') { DP[i+1][1] += DP[i][0] + DP[i][1] + DP[i][2]; } if(c == 'R' || c == '.') { DP[i+1][2] += DP[i][0] + DP[i][1] + DP[i][2]; } } mint ans = DP[n][0] + DP[n][1] + DP[n][2]; cout << ans.val << endl; return ans_type(); } ans_type solve_simple(){ return ans_type(); } void output(ans_type ans){ return; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); check_with_simple_solution = 0; calc_time = 0; random_input = 0; debug_output = 0; num_of_testcase = 1; if(num_of_testcase == 0) cin >> num_of_testcase; pre_solve(); if(check_with_simple_solution){ for(int i = 0; i < num_of_testcase; i++){ if(debug_output) cout << "begin case " << i << " " << string(16, '=') << endl; input(); ans_type ans = solve(); if(debug_output) cout << string(16, '=') << endl; ans_type ans_simple = solve_simple(); if(ans != ans_simple){ cout << "input: " << endl; output_input(); cout << "output: " << endl; output(ans); cout << "expected: " << endl; output(ans_simple); } if(debug_output) cout << "end case " << i << " " << string(16, '=') << endl; } } else{ int64_t time_start = get_time(); for(int i = 0; i < num_of_testcase; i++){ input(); output(solve()); } int64_t time_end = get_time(); if(calc_time){ double time_per_case = (time_end - time_start) / (1e9 * num_of_testcase); cout << fixed << setprecision(3) << time_per_case << "[second/case]" << endl; } } return 0; }