結果
問題 | No.2524 Stripes |
ユーザー | shobonvip |
提出日時 | 2023-10-27 22:07:54 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 676 ms / 7,000 ms |
コード長 | 2,794 bytes |
コンパイル時間 | 4,726 ms |
コンパイル使用メモリ | 274,952 KB |
実行使用メモリ | 11,848 KB |
最終ジャッジ日時 | 2024-09-25 14:13:02 |
合計ジャッジ時間 | 11,550 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 327 ms
7,988 KB |
testcase_04 | AC | 13 ms
6,940 KB |
testcase_05 | AC | 264 ms
6,976 KB |
testcase_06 | AC | 329 ms
7,872 KB |
testcase_07 | AC | 640 ms
11,312 KB |
testcase_08 | AC | 642 ms
11,180 KB |
testcase_09 | AC | 121 ms
6,940 KB |
testcase_10 | AC | 305 ms
7,532 KB |
testcase_11 | AC | 12 ms
6,944 KB |
testcase_12 | AC | 68 ms
6,944 KB |
testcase_13 | AC | 670 ms
11,652 KB |
testcase_14 | AC | 669 ms
11,848 KB |
testcase_15 | AC | 664 ms
11,764 KB |
testcase_16 | AC | 664 ms
11,848 KB |
testcase_17 | AC | 676 ms
11,724 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,944 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ // (start, end): // FFT struct S{ vector<mint> bb; vector<mint> br; vector<mint> rb; vector<mint> rr; }; int n; cin >> n; vector<char> c(n); rep(i,0,n){ cin >> c[i]; } auto calc = [&](auto self, int l, int r) -> S { if (l + 1 == r){ if (c[l] == 'R'){ return { {0, 0}, {0, 0}, {0, 0}, {0, 1} }; }else{ return { {0, 1}, {0, 0}, {0, 0}, {0, 0} }; } } int m = (l + r) / 2; S v1 = self(self, l, m); S v2 = self(self, m, r); S v3; vector<mint> bb1 = convolution(v1.br, v2.bb); vector<mint> bb2 = convolution(v1.bb, v2.rb); vector<mint> rr1 = convolution(v1.rr, v2.br); vector<mint> rr2 = convolution(v1.rb, v2.rr); vector<mint> br1 = convolution(v1.bb, v2.rr); vector<mint> br2 = convolution(v1.br, v2.br); vector<mint> rb1 = convolution(v1.rr, v2.bb); vector<mint> rb2 = convolution(v1.rb, v2.rb); v3.bb = vector<mint>((int)bb1.size()); v3.br = vector<mint>((int)bb1.size()); v3.rb = vector<mint>((int)bb1.size()); v3.rr = vector<mint>((int)bb1.size()); rep(i,0,(int)bb1.size()){ v3.bb[i] = bb1[i] + bb2[i]; v3.rr[i] = rr1[i] + rr2[i]; v3.rb[i] = rb1[i] + rb2[i]; v3.br[i] = br1[i] + br2[i]; } rep(i,0,(int)v1.bb.size()){ v3.bb[i] += v1.bb[i]; v3.rr[i] += v1.rr[i]; v3.br[i] += v1.br[i]; v3.rb[i] += v1.rb[i]; } rep(i,0,(int)v2.bb.size()){ v3.bb[i] += v2.bb[i]; v3.rr[i] += v2.rr[i]; v3.br[i] += v2.br[i]; v3.rb[i] += v2.rb[i]; } return v3; }; S ans = calc(calc, 0, n); vector<mint> anv(n+1); assert((int)ans.bb.size() == n+1); rep(i,0,n+1){ anv[i] = ans.bb[i] + ans.br[i] + ans.rr[i] + ans.rb[i]; } rep(i,1,n+1){ cout << anv[i].val() << '\n'; } }