結果

問題 No.140 みんなで旅行
ユーザー tassei903tassei903
提出日時 2022-04-07 23:45:29
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,197 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 305,588 KB
最終ジャッジ日時 2023-08-18 19:08:30
合計ジャッジ時間 8,512 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
71,200 KB
testcase_01 AC 75 ms
71,268 KB
testcase_02 AC 282 ms
78,568 KB
testcase_03 AC 77 ms
71,152 KB
testcase_04 AC 79 ms
71,364 KB
testcase_05 AC 75 ms
71,160 KB
testcase_06 AC 75 ms
71,524 KB
testcase_07 AC 78 ms
71,364 KB
testcase_08 AC 82 ms
76,468 KB
testcase_09 AC 84 ms
76,464 KB
testcase_10 AC 82 ms
76,496 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n = ni()
mod = 10**9+7
dp = [[0 for j in range(n*2+1)]for k in range(n+1)]
dp[0][0] = 1
for i in range(n):
    odp = [[0 for j in range(n*2+1)]for k in range(n+1)]
    dp, odp = odp, dp
    for j in range(n+1):
        for k in range(n*2+1):
            now = odp[j][k]
            if j < n:
                dp[j+1][k] += now
                dp[j+1][k] %= mod
            dp[j][k] += now*(j*k*2+j*j+k*(k-1))%mod
            dp[j][k] %= mod
            if j < n and k > 0:
                dp[j+1][k-1] += now * k
                dp[j+1][k-1] %= mod
            if k + 1 <= 2*n:
                dp[j][k+1] += now * (j+k)*2
                dp[j][k+1] %= mod
            if k + 2 <= 2*n:
                dp[j][k+2] += now 
                dp[j][k+2] %= mod
    #print(dp)
ans = 0
for i in range(n+1):
    ans += dp[i][0]
    ans %= mod
print(ans)
0