結果

問題 No.2668 Trees on Graph Paper
ユーザー ニックネームニックネーム
提出日時 2024-03-08 23:16:30
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 463 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2024-03-08 23:16:41
合計ジャッジ時間 10,000 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 611 ms
76,012 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 36 ms
53,460 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
x = 1; dp = [0]*8+[1]
for i in range(1,2*n): x = x*i%m
for i in range(2,2*n-1):
    eq = [0]*9
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if k==2 and l==0: continue
                if j!=2 and k!=1 and l!=0: eq[3*k+l] += dp[3*j+k]*(i-2)
                else: eq[3*k+l] += dp[3*j+k]
    dp = [v%m for v in eq]
    if i%2==0: x = x*(dp[0]+dp[1]+dp[3]+dp[4]+dp[6]+dp[7])%m
print(x)
0