#include #include #define MOD 998244353ll using namespace std; using namespace atcoder; using ll = long long; struct Vector2 { vector v1; vector v2; Vector2(void) { } Vector2(vector v1, vector v2) { this->v1 = v1; this->v2 = v2; } }; ll n; vector operator*(const vector& left, const vector& right){ vector ret = convolution(left, right); while(ret.size() > n + 1){ ret.pop_back(); } return ret; } vector operator+(const vector& left, const vector& right){ vector ret(max(left.size(), right.size())); for(int i = 0; i < left.size(); ++i){ ret[i] += left[i]; } for(int i = 0; i < right.size(); ++i){ ret[i] += right[i]; ret[i] %= MOD; } return ret; } struct Matrix22 { vector v11, v12, v21, v22; Matrix22(void) { } Matrix22(vector v11, vector v12, vector v21, vector v22) { this->v11 = v11; this->v12 = v12; this->v21 = v21; this->v22 = v22; } Matrix22 operator*(const Matrix22 other) const { return Matrix22((this->v11 * other.v11) + (this->v12 * other.v21), (this->v11 * other.v12) + (this->v12 * other.v22), (this->v21 * other.v11) + (this->v22 * other.v21), (this->v21 * other.v12) + (this->v22 * other.v22)); } Vector2 operator*(const Vector2 other) const { return Vector2((this->v11 * other.v1) + (this->v12 * other.v2), (this->v21 * other.v1) + (this->v22 * other.v2)); } }; int main(){ cin >> n; string s; cin >> s; vector M(n, Matrix22()); for(int i = 0; i < n; ++i){ if(s[i] == 'R'){ M[i] = Matrix22({1}, {0, 1}, {0}, {1}); } else{ M[i] = Matrix22({1}, {0}, {0, 1}, {1}); } } Vector2 v_init({1}, {1}); while(M.size() > 1){ vector M_next = {}; for(int i = 0; i < M.size() - 1; i += 2){ M_next.push_back(M[i + 1] * M[i]); } M = M_next; } Vector2 v = M[0] * v_init; vector ans = v.v1 + v.v2; for(int i = 1; i < n + 1; ++i){ if(i >= ans.size()){ cout << 0 << endl; continue; } cout << ans[i] << endl; } return 0; }