結果

問題 No.2668 Trees on Graph Paper
ユーザー ゼットゼット
提出日時 2024-03-08 23:15:42
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 672 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 847,532 KB
最終ジャッジ日時 2024-03-08 23:15:48
合計ジャッジ時間 5,715 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 1,065 ms
310,844 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 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 37 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 36 ms
53,460 KB
testcase_13 AC 38 ms
53,456 KB
testcase_14 MLE -
testcase_15 -- -
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,mod=map(int,input().split())
dp=[[0]*3 for i in range(2*N)]
dp[1][2]=1
score=[[0]*3 for i in range(2*N)]
score[1][2]=1
for i in range(1,2*N-1):
  for j in range(3):
    for k in range(3):
      if j==2 and k==0:
        continue
      dp[i+1][k]+=dp[i][j]
      dp[i+1][k]%=mod
      if k<=j:
        score[i+1][k]+=score[i][j]
      elif k==1 and j==0:
        score[i+1][k]+=score[i][j]*(i-1)
      elif k==2 and j==1:
        score[i+1][k]+=score[i][j]*i
      else:
        score[i+1][k]+=score[i][j]*i*(i-1)
      score[i+1][k]%=mod
result=1
for x in range(1,2*N):
  result*=x
  result%=mod
for i in range(1,N):
  result*=score[2*i+1][0]
  result%=mod
print(result)
0