結果

問題 No.2135 C5
ユーザー shobonvipshobonvip
提出日時 2022-10-21 00:26:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 923 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2024-04-10 06:39:33
合計ジャッジ時間 12,677 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 39 ms
53,604 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 38 ms
53,540 KB
testcase_07 WA -
testcase_08 AC 38 ms
53,356 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 38 ms
53,748 KB
testcase_12 AC 38 ms
54,348 KB
testcase_13 AC 38 ms
54,228 KB
testcase_14 AC 37 ms
53,700 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 474 ms
76,940 KB
testcase_26 AC 126 ms
74,824 KB
testcase_27 AC 124 ms
76,544 KB
testcase_28 AC 402 ms
76,460 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 478 ms
76,756 KB
testcase_34 AC 494 ms
76,680 KB
testcase_35 AC 38 ms
53,492 KB
testcase_36 WA -
testcase_37 AC 37 ms
52,568 KB
testcase_38 AC 38 ms
53,136 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 158 ms
76,796 KB
testcase_43 AC 59 ms
69,048 KB
testcase_44 AC 39 ms
55,708 KB
testcase_45 AC 268 ms
76,744 KB
testcase_46 AC 58 ms
67,572 KB
testcase_47 AC 142 ms
76,564 KB
testcase_48 AC 473 ms
77,028 KB
testcase_49 AC 473 ms
76,864 KB
testcase_50 AC 484 ms
76,716 KB
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
N, M = map(int,input().split())
fact = [1]*(N+1)
factinv = [1]*(N+1)

for i in range(2, N+1):
	fact[i] = fact[i-1] * i % mod

factinv[-1] = pow(fact[-1], mod-2, mod)
for i in range(N-1, 1, -1):
	factinv[i] = factinv[i+1] * (i+1) % mod

def cmb(a, b):
	if (a < b) or (b < 0):
		return 0
	return fact[a] * factinv[b] % mod * factinv[a-b] % mod

inv2 = pow(2, mod-2, mod)

dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 1

for i in range(N+1):
	for j in range(N+1):
		# パス
		if i+1 <= N:
			dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod
		for k in range(2, min(N-i, N-j+1)+1):
			dp[i+k][j+k-1] = (dp[i+k][j+k-1] + cmb(N-i-1, k-1) * dp[i][j] % mod * fact[k] % mod * inv2) % mod
		# 閉路
		for k in range(5, min(N-i, N-j)+1):
			dp[i+k][j+k] = (dp[i+k][j+k] + cmb(N-i-1, k-1) * dp[i][j] % mod * fact[k-1] % mod * inv2) % mod

if M < N*(N-1)//2 - N:
	print(0)
else:
	print(sum(dp[N][N*(N-1)//2-M:]) % mod)
0