結果

問題 No.2668 Trees on Graph Paper
ユーザー chineristACchineristAC
提出日時 2024-03-08 23:46:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,922 ms / 3,000 ms
コード長 984 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 76,580 KB
最終ジャッジ日時 2024-03-08 23:47:17
合計ジャッジ時間 21,991 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
56,112 KB
testcase_01 AC 40 ms
56,112 KB
testcase_02 AC 41 ms
56,112 KB
testcase_03 AC 215 ms
76,580 KB
testcase_04 AC 39 ms
56,112 KB
testcase_05 AC 45 ms
56,112 KB
testcase_06 AC 39 ms
56,112 KB
testcase_07 AC 39 ms
56,112 KB
testcase_08 AC 40 ms
56,112 KB
testcase_09 AC 41 ms
56,112 KB
testcase_10 AC 41 ms
56,112 KB
testcase_11 AC 41 ms
56,112 KB
testcase_12 AC 42 ms
56,112 KB
testcase_13 AC 41 ms
56,112 KB
testcase_14 AC 1,115 ms
76,580 KB
testcase_15 AC 1,674 ms
76,580 KB
testcase_16 AC 854 ms
76,580 KB
testcase_17 AC 148 ms
76,580 KB
testcase_18 AC 1,586 ms
76,580 KB
testcase_19 AC 1,369 ms
76,580 KB
testcase_20 AC 1,468 ms
76,580 KB
testcase_21 AC 1,415 ms
76,580 KB
testcase_22 AC 1,466 ms
76,580 KB
testcase_23 AC 942 ms
76,580 KB
testcase_24 AC 1,868 ms
76,580 KB
testcase_25 AC 1,891 ms
76,580 KB
testcase_26 AC 1,922 ms
76,580 KB
testcase_27 AC 1,873 ms
76,580 KB
testcase_28 AC 44 ms
56,112 KB
testcase_29 AC 43 ms
56,112 KB
testcase_30 AC 43 ms
56,112 KB
testcase_31 AC 55 ms
56,112 KB
testcase_32 AC 43 ms
56,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,M = mi()

"""
状態:自分からみて埋まっていない最小値が(-1,0,1)の状態
"""

res = 1
dp = [1,1,1]
for i in range(N-2):
    for j in range(2):
        ndp = [0,0,0]
        x = 2 * (i+1) + j
        for mini in (-1,0,1):
            for nxt_mini in (-1,0,1):
                if mini > nxt_mini+1:
                    continue
                deg = nxt_mini - mini + 1
                if deg == 0:
                    ndp[nxt_mini] += dp[mini] * x % M
                else:
                    ndp[nxt_mini] += dp[mini] % M
                ndp[nxt_mini] %= M
        dp = ndp
        #print(dp)
    res *= dp[1]
    res %= M

#print(res)
for x in range(1,2*N):
    res = res * x % M

print(res)

                    
0