結果

問題 No.2711 Connecting Lights
ユーザー ntudantuda
提出日時 2024-04-06 13:29:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 809 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 70,756 KB
最終ジャッジ日時 2024-04-06 13:29:54
合計ジャッジ時間 4,048 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 50 ms
66,500 KB
testcase_06 AC 43 ms
59,992 KB
testcase_07 AC 49 ms
62,396 KB
testcase_08 AC 48 ms
62,260 KB
testcase_09 AC 53 ms
66,500 KB
testcase_10 AC 51 ms
66,500 KB
testcase_11 AC 57 ms
68,548 KB
testcase_12 AC 55 ms
68,424 KB
testcase_13 AC 58 ms
68,572 KB
testcase_14 AC 48 ms
64,328 KB
testcase_15 AC 52 ms
66,376 KB
testcase_16 AC 50 ms
66,500 KB
testcase_17 AC 51 ms
66,500 KB
testcase_18 AC 51 ms
64,328 KB
testcase_19 AC 54 ms
68,548 KB
testcase_20 AC 58 ms
68,580 KB
testcase_21 AC 53 ms
66,500 KB
testcase_22 AC 49 ms
62,396 KB
testcase_23 AC 50 ms
66,528 KB
testcase_24 AC 51 ms
64,452 KB
testcase_25 AC 52 ms
66,500 KB
testcase_26 AC 58 ms
70,756 KB
testcase_27 AC 58 ms
70,756 KB
testcase_28 AC 59 ms
70,756 KB
testcase_29 AC 59 ms
70,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import comb

MOD = 998244353
N,M,K = map(int,input().split())
X = [[0] * (N+1) for _ in range(N+1)]

for i in range(N+1):
    for j in range(N+1):
        if i < K or j < K:
            continue
        if i + j - N >= K:
            X[i][j] = comb(N,j)
        elif i == K:
            X[i][j] = comb(N-i,j-K)
        elif j == K:
            X[i][j] = comb(i,K)
        else:
            if N - i >= j:
                X[i][j] = comb(N,j) - comb(N-i,j)
            else:
                X[i][j] = comb(N,j) - comb(i,j - K)

dp = [[0] * (N+1) for _ in range(M)]
for i in range(N+1):
    dp[0][i] = comb(N,i)
for i in range(M-1):
    for j in range(N+1):
        for k in range(N+1):
            dp[i+1][k] += dp[i][j] * X[j][k]
            dp[i+1][k] %= MOD
ans = sum(dp[-1])
ans %= MOD
print(ans)
0