結果

問題 No.140 みんなで旅行
ユーザー convexineqconvexineq
提出日時 2021-02-14 02:56:15
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 765 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 276,032 KB
最終ジャッジ日時 2023-09-28 12:31:54
合計ジャッジ時間 8,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,120 KB
testcase_01 AC 73 ms
71,036 KB
testcase_02 AC 204 ms
77,748 KB
testcase_03 AC 73 ms
71,124 KB
testcase_04 AC 73 ms
71,228 KB
testcase_05 AC 74 ms
71,300 KB
testcase_06 AC 75 ms
71,104 KB
testcase_07 AC 73 ms
71,068 KB
testcase_08 AC 75 ms
70,916 KB
testcase_09 AC 76 ms
71,216 KB
testcase_10 AC 82 ms
76,064 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 #

n = int(input())
MOD = 10**9+7
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for _ in range(n):
    ndp = [[0]*(n+1) for _ in range(n+1)]
    for a in range(n+1):
        for b in range(n+1):
            x = dp[a][b]
            ndp[a][b] += x*(a*a-(a-b))
            ndp[a][b] %= MOD
            if b+1 <= n:
                ndp[a][b+1] += x*(a-b)
                ndp[a][b+1] %= MOD
            if a+1 <= n:
                ndp[a+1][b] += x*2*a
                ndp[a+1][b] %= MOD
            if a+1 <= n and b+1 <= n:
                ndp[a+1][b+1] += x
                ndp[a+1][b+1] %= MOD
            if a+2 <= n:
                ndp[a+2][b] += x
                ndp[a+2][b] %= MOD
    dp = ndp

ans = 0
for i in range(n+1):
    ans += dp[i][i]
print(ans%MOD)
0