結果

問題 No.2378 Cards and Subsequences
ユーザー yamate11yamate11
提出日時 2023-06-13 20:59:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 930 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 166,248 KB
最終ジャッジ日時 2023-09-28 21:38:44
合計ジャッジ時間 9,382 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,240 KB
testcase_01 AC 74 ms
70,996 KB
testcase_02 AC 90 ms
76,676 KB
testcase_03 AC 251 ms
80,688 KB
testcase_04 AC 325 ms
82,784 KB
testcase_05 AC 273 ms
80,188 KB
testcase_06 AC 627 ms
89,296 KB
testcase_07 AC 695 ms
91,280 KB
testcase_08 AC 785 ms
94,532 KB
testcase_09 AC 892 ms
96,140 KB
testcase_10 AC 398 ms
84,532 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import sys

def debug(*msg):
    print(*msg, file=sys.stderr)

def intdec(x):
    return int(x) - 1

N, M, K = map(int, input().strip().split())
S = list(map(intdec, input().strip().split()))
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))

rec = [-1 for _ in range(M + 1)]
prev = [0 for _ in range(N)]
for i in range(N):
    prev[i] = rec[S[i]]
    rec[S[i]] = i
debug(prev)

primeB = 998244353

acc = [[0 for k in range(K + 1)] for n in range(N + 1)]
acc[0][0] = 1
for i in range(N):
    acc[i + 1] = acc[i][:]
    for k in range(K + 1):
        exc = 0 if prev[i] < 0 else acc[prev[i]][k]
        v = (acc[i][k] - exc) % primeB

        def op(a):
            debug("  called", a, v)
            if a <= K:
                acc[i + 1][a] = (acc[i + 1][a] + v) % primeB
        
        op(k + A[S[i]])
        op(k + B[S[i]])
    debug(acc[i + 1])

print(acc[N][K])
0