結果

問題 No.2215 Slide Subset Sum
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-11 02:53:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,269 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 435,552 KB
最終ジャッジ日時 2023-09-22 02:53:59
合計ジャッジ時間 32,642 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 68 ms
71,076 KB
testcase_06 AC 72 ms
75,288 KB
testcase_07 AC 69 ms
71,284 KB
testcase_08 WA -
testcase_09 AC 69 ms
70,964 KB
testcase_10 AC 69 ms
71,160 KB
testcase_11 AC 70 ms
71,284 KB
testcase_12 AC 81 ms
76,308 KB
testcase_13 WA -
testcase_14 AC 83 ms
76,100 KB
testcase_15 AC 72 ms
75,368 KB
testcase_16 AC 85 ms
76,464 KB
testcase_17 AC 1,447 ms
254,472 KB
testcase_18 AC 1,258 ms
231,440 KB
testcase_19 WA -
testcase_20 AC 1,071 ms
265,860 KB
testcase_21 AC 1,238 ms
137,644 KB
testcase_22 AC 1,169 ms
281,768 KB
testcase_23 AC 1,776 ms
415,156 KB
testcase_24 AC 2,107 ms
416,988 KB
testcase_25 AC 1,491 ms
376,224 KB
testcase_26 AC 1,197 ms
283,660 KB
testcase_27 WA -
testcase_28 AC 160 ms
92,632 KB
testcase_29 AC 171 ms
85,444 KB
testcase_30 WA -
testcase_31 AC 638 ms
199,760 KB
testcase_32 AC 198 ms
82,416 KB
testcase_33 AC 834 ms
118,640 KB
testcase_34 AC 659 ms
175,752 KB
testcase_35 WA -
testcase_36 AC 361 ms
131,336 KB
testcase_37 AC 1,017 ms
435,552 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 1,085 ms
265,484 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1,429 ms
358,484 KB
testcase_46 AC 1,595 ms
358,432 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):
    if not A:
        return
    for i in range(K):
        dp[0][i] = 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)
    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, min(M*i+M+M, len(A)))]

        # dpL = list(calc_dp(K, L))[::-1]
        # dpR = list(calc_dp(K, R))
        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):
            if j >= len(R):
                break
            answer.append(merge(dpL[j+1], dpR[j], K))

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


main()
0