結果

問題 No.2215 Slide Subset Sum
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-11 02:59:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,140 bytes
コンパイル時間 957 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 450,080 KB
最終ジャッジ日時 2023-09-22 02:58:57
合計ジャッジ時間 45,093 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 77 ms
71,016 KB
testcase_06 AC 83 ms
75,752 KB
testcase_07 AC 76 ms
71,076 KB
testcase_08 WA -
testcase_09 AC 76 ms
71,148 KB
testcase_10 AC 76 ms
70,960 KB
testcase_11 AC 76 ms
71,160 KB
testcase_12 AC 96 ms
76,488 KB
testcase_13 WA -
testcase_14 AC 93 ms
76,252 KB
testcase_15 AC 83 ms
75,760 KB
testcase_16 AC 94 ms
76,216 KB
testcase_17 AC 1,963 ms
262,620 KB
testcase_18 AC 1,734 ms
236,352 KB
testcase_19 WA -
testcase_20 AC 1,653 ms
274,376 KB
testcase_21 AC 1,510 ms
139,964 KB
testcase_22 AC 1,724 ms
290,888 KB
testcase_23 AC 2,512 ms
427,484 KB
testcase_24 TLE -
testcase_25 AC 2,152 ms
392,684 KB
testcase_26 AC 1,743 ms
291,852 KB
testcase_27 WA -
testcase_28 AC 204 ms
94,324 KB
testcase_29 AC 204 ms
85,716 KB
testcase_30 WA -
testcase_31 AC 928 ms
203,776 KB
testcase_32 AC 237 ms
82,584 KB
testcase_33 AC 1,018 ms
121,500 KB
testcase_34 AC 871 ms
182,564 KB
testcase_35 WA -
testcase_36 AC 509 ms
132,356 KB
testcase_37 AC 1,728 ms
450,080 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 1,642 ms
273,792 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 2,032 ms
367,616 KB
testcase_46 AC 2,346 ms
367,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def merge(X, Y, K):
    res = X[0] * Y[0] - 1
    for i in range(1, K):
        res += X[i] * Y[K - i]
        res %= mod
    return res


def calc_dp(dp, K, A):
    for i in range(len(dp)):
        for j in range(K):
            dp[i][j] = 0
    dp[0][0] = 1
    dp[0][A[0]] = 1
    for i, a in enumerate(A[1:], 1):
        for j in range(K):
            dp[i][j] = dp[i-1][j] + dp[i-1][j-a]
            if dp[i][j] >= mod:
                dp[i][j] -= mod


def main():
    N, M, K = map(int, input().split())
    block = (N + M - 1) // M
    A = [0] * (block * M + M)
    for i, a in enumerate(map(int, input().split())):
        A[i] = a

    dpL = [[0] * K for _ in range(M)]
    dpR = [[0] * K for _ in range(M)]

    answer = []
    for i in range(block):
        L = [A[j] for j in range(M*i, M*i+M)][::-1]
        R = [A[j] for j in range(M*i+M, M*i+2*M)]

        calc_dp(dpL, K, L)
        dpL.reverse()
        calc_dp(dpR, K, R)

        answer.append((dpL[0][0] - 1) % mod)
        for j in range(M - 1):
            answer.append(merge(dpL[j+1], dpR[j], K))

    print(*answer[:N - M + 1], sep="\n")


main()
0