結果

問題 No.2524 Stripes
ユーザー MasKoaTSMasKoaTS
提出日時 2023-09-27 15:34:11
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 1,474 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 33,244 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-27 15:34:33
合計ジャッジ時間 16,131 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2,971 ms
4,376 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 723 ms
4,376 KB
testcase_06 AC 2,981 ms
4,376 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 愚直

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <stdio.h>
#define N_MAX 100000
#define u32 unsigned int
#define MOD 998244353

int main(){
    int n;  scanf("%d", &n);
    char s[N_MAX];  scanf("%s", s);

    int a[N_MAX] = { 0 };
    for(int i = 0; i < N_MAX; ++i){
        if(s[i] == 'R'){
            a[i] = 1;
        }
    }

    u32 dp0[N_MAX + 1] = { 0 };
    u32 dp1[N_MAX + 1] = { 0 };
    u32 ndp0[N_MAX + 1] = { 0 };
    u32 ndp1[N_MAX + 1] = { 0 };
    dp0[0] = dp1[0] = 1;
    if(a[0]){
        dp1[1] = 1;
    }
    else{
        dp0[1] = 1;
    }
    for(int i = 1; i < n; ++i){
        // printf("%d\n", i);
        ndp0[0] = dp0[0];
        ndp1[0] = dp1[0];
        for(int j = 1; j < n + 1; ++j){
            ndp0[j] = dp0[j];
            ndp1[j] = dp1[j];
            if(a[i]){
                ndp1[j] += dp0[j - 1];
                if(ndp1[j] >= MOD){
                    ndp1[j] -= MOD;
                }
            }
            else{
                ndp0[j] += dp1[j - 1];
                if(ndp0[j] >= MOD){
                    ndp0[j] -= MOD;
                }
            }
        }
        for(int j = 0; j < n + 1; ++j){
            dp0[j] = ndp0[j];
            dp1[j] = ndp1[j];
        }
    }

    for(int j = 1; j < n + 1; ++j){
        u32 ans = dp0[j] + dp1[j];
        if(ans >= MOD){
            ans -= MOD;
        }
        printf("%u\n", ans);
    }

    return 0;
}
0