結果

問題 No.93 ペガサス
ユーザー ytftytft
提出日時 2022-11-10 14:36:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 549 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 45,408 KB
最終ジャッジ日時 2023-09-30 23:13:45
合計ジャッジ時間 13,562 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
29,548 KB
testcase_01 AC 125 ms
29,632 KB
testcase_02 AC 124 ms
29,604 KB
testcase_03 AC 126 ms
29,556 KB
testcase_04 AC 1,730 ms
33,312 KB
testcase_05 AC 691 ms
31,072 KB
testcase_06 AC 509 ms
30,436 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
input=lambda:sys.stdin.readline().rstrip()
mod=10**9+7
N=int(input())
if N<=3:
	print([1,2,2][N-1])
	sys.exit()
dp=np.zeros((N+1,N,2,2),dtype=int)
dp[4,2,1,1]=8
dp[4,1,0,1]=4
dp[4,1,1,0]=4
dp[4,0,0,0]=8
for i in range(4,N):
	for j in range(i):
		for k in range(2):
			for l in range(2):
				dp[i,j,k,l]%=mod
				dp[i+1,j+1,l,1]+=(2-k)*dp[i,j,k,l]
				dp[i+1,j-1,l,0]+=(j-k-l)*dp[i,j,k,l]
				dp[i+1,j,l,0]+=(i-j-1+k)*dp[i,j,k,l]
				dp[i+1,j-1,0,0]+=l*dp[i,j,k,l]
				dp[i+1,j,l,1]+=k*dp[i,j,k,l]
print(dp[N,0,0,0]%mod)
0