結果

問題 No.1513 simple 門松列 problem
ユーザー 👑 rin204rin204
提出日時 2022-01-28 21:19:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 950 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 148,052 KB
最終ジャッジ日時 2023-08-28 18:56:10
合計ジャッジ時間 5,242 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,328 KB
testcase_01 AC 73 ms
75,948 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n, k = map(int, input().split())
edges = [[] for _ in range(k * k)]
f = lambda x, y: x * k + y
dp = [0] * (k * k)
tot = [0] * (k * k)
for i in range(k):
    for j in range(i + 1, k):
        dp[f(i, j)] = 1
        tot[f(i, j)] = i + j
        for i2 in range(j):
            if i2 == i:
                continue
            edges[f(i, j)].append((f(j, i2)))

for i in range(k):
    for j in range(i):
        dp[f(i, j)] = 1
        tot[f(i, j)] = i + j
        for i2 in range(j + 1, k):
            if i2 == i:
                continue
            edges[f(i, j)].append((f(j, i2)))

for _ in range(n - 2):
    dp2 = [0] * (k * k)
    tot2 = [0] * (k * k)
    for pos in range(k * k):
        for npos in edges[pos]:
            dp2[npos] += dp[pos]
            dp2[npos] %= MOD
            tot2[npos] += tot[pos] + dp[pos] * (npos % k)
            tot2[npos] %= MOD
    dp = dp2
    tot = tot2
print(sum(dp) % MOD, sum(tot) % MOD)
0