結果

問題 No.2215 Slide Subset Sum
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-11 02:43:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,153 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 448,884 KB
最終ジャッジ日時 2023-09-22 02:46:53
合計ジャッジ時間 37,254 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 71 ms
71,284 KB
testcase_06 AC 76 ms
75,948 KB
testcase_07 AC 72 ms
71,488 KB
testcase_08 WA -
testcase_09 AC 70 ms
71,488 KB
testcase_10 AC 69 ms
71,532 KB
testcase_11 AC 71 ms
71,468 KB
testcase_12 AC 82 ms
76,200 KB
testcase_13 WA -
testcase_14 AC 84 ms
76,484 KB
testcase_15 AC 75 ms
75,684 KB
testcase_16 AC 86 ms
76,564 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1,374 ms
271,000 KB
testcase_21 WA -
testcase_22 AC 1,476 ms
289,524 KB
testcase_23 AC 2,067 ms
432,084 KB
testcase_24 AC 2,538 ms
433,988 KB
testcase_25 AC 1,870 ms
391,784 KB
testcase_26 AC 1,477 ms
291,596 KB
testcase_27 WA -
testcase_28 AC 175 ms
94,388 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 821 ms
203,496 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 434 ms
132,756 KB
testcase_37 AC 1,366 ms
448,884 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1,782 ms
367,284 KB
testcase_46 AC 2,116 ms
367,296 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):
    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