結果

問題 No.2215 Slide Subset Sum
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-11 02:30:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 446,608 KB
最終ジャッジ日時 2023-09-22 02:35:20
合計ジャッジ時間 28,556 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 497 ms
100,164 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 75 ms
71,228 KB
testcase_06 AC 78 ms
75,836 KB
testcase_07 AC 77 ms
71,600 KB
testcase_08 AC 80 ms
71,268 KB
testcase_09 WA -
testcase_10 AC 79 ms
71,344 KB
testcase_11 AC 79 ms
71,284 KB
testcase_12 AC 87 ms
76,508 KB
testcase_13 AC 88 ms
76,304 KB
testcase_14 AC 85 ms
76,344 KB
testcase_15 AC 77 ms
71,128 KB
testcase_16 AC 90 ms
76,576 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 769 ms
269,848 KB
testcase_21 WA -
testcase_22 AC 802 ms
284,716 KB
testcase_23 AC 1,300 ms
408,384 KB
testcase_24 AC 1,215 ms
410,256 KB
testcase_25 AC 1,173 ms
374,336 KB
testcase_26 AC 824 ms
285,372 KB
testcase_27 WA -
testcase_28 AC 170 ms
92,212 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 485 ms
202,404 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 283 ms
131,508 KB
testcase_37 AC 1,428 ms
446,608 KB
testcase_38 AC 350 ms
139,532 KB
testcase_39 AC 507 ms
100,136 KB
testcase_40 AC 260 ms
98,616 KB
testcase_41 AC 77 ms
71,496 KB
testcase_42 AC 769 ms
269,692 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1,119 ms
357,224 KB
testcase_46 AC 1,113 ms
357,176 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(K, A):
    dp = [0] * K
    dp[0] = 1
    for a in A:
        tmp = [0] * K
        for i in range(K):
            tmp[i] = dp[i - a]
        for i in range(K):
            dp[i] += tmp[i]
            dp[i] %= mod
        yield dp[:]


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

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

        dpL = list(calc_dp(K, L))[::-1]
        dpR = list(calc_dp(K, R))

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

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


main()
0