結果

問題 No.2215 Slide Subset Sum
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-11 02:44:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,197 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 448,544 KB
最終ジャッジ日時 2023-09-22 02:47:50
合計ジャッジ時間 35,685 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 69 ms
71,280 KB
testcase_06 AC 73 ms
75,944 KB
testcase_07 AC 70 ms
71,240 KB
testcase_08 WA -
testcase_09 AC 70 ms
71,432 KB
testcase_10 AC 70 ms
71,420 KB
testcase_11 AC 71 ms
71,376 KB
testcase_12 AC 83 ms
76,408 KB
testcase_13 WA -
testcase_14 AC 84 ms
76,332 KB
testcase_15 AC 73 ms
75,452 KB
testcase_16 AC 85 ms
76,608 KB
testcase_17 AC 1,684 ms
262,712 KB
testcase_18 AC 1,462 ms
235,960 KB
testcase_19 WA -
testcase_20 AC 1,354 ms
271,124 KB
testcase_21 AC 1,221 ms
139,388 KB
testcase_22 AC 1,445 ms
289,644 KB
testcase_23 AC 1,928 ms
432,284 KB
testcase_24 AC 2,342 ms
431,924 KB
testcase_25 AC 1,772 ms
391,640 KB
testcase_26 AC 1,460 ms
290,956 KB
testcase_27 WA -
testcase_28 AC 173 ms
94,336 KB
testcase_29 AC 174 ms
85,472 KB
testcase_30 WA -
testcase_31 AC 748 ms
203,580 KB
testcase_32 AC 204 ms
83,060 KB
testcase_33 AC 857 ms
120,004 KB
testcase_34 AC 730 ms
179,328 KB
testcase_35 WA -
testcase_36 AC 409 ms
132,664 KB
testcase_37 AC 1,367 ms
448,544 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 1,378 ms
273,684 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1,676 ms
366,940 KB
testcase_46 AC 1,980 ms
367,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
tmp = [0] * 100


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(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 + 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)]

        # 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):
            answer.append(merge(dpL[j+1], dpR[j], K))

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


main()
0