結果

問題 No.2668 Trees on Graph Paper
ユーザー ゼットゼット
提出日時 2024-03-08 23:26:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 669 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,120 KB
最終ジャッジ日時 2024-03-08 23:27:26
合計ジャッジ時間 35,682 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 357 ms
76,004 KB
testcase_04 AC 40 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 39 ms
53,460 KB
testcase_08 AC 39 ms
53,460 KB
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 41 ms
53,460 KB
testcase_11 AC 39 ms
53,460 KB
testcase_12 AC 40 ms
53,460 KB
testcase_13 AC 39 ms
53,460 KB
testcase_14 AC 1,921 ms
76,016 KB
testcase_15 AC 2,694 ms
75,680 KB
testcase_16 AC 1,454 ms
76,096 KB
testcase_17 AC 242 ms
76,120 KB
testcase_18 AC 2,541 ms
75,684 KB
testcase_19 AC 2,439 ms
76,016 KB
testcase_20 AC 2,125 ms
75,684 KB
testcase_21 AC 2,526 ms
76,016 KB
testcase_22 AC 2,547 ms
76,016 KB
testcase_23 AC 1,662 ms
76,016 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 40 ms
53,460 KB
testcase_29 AC 40 ms
53,460 KB
testcase_30 AC 38 ms
53,460 KB
testcase_31 AC 39 ms
53,460 KB
testcase_32 AC 39 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,mod=map(int,input().split())
dp=[0]*3
dp[2]=1
score=[0]*3
score[2]=1
result=1
for x in range(1,2*N):
  result*=x
  result%=mod
for i in range(1,2*N-1):
  dp2=[0]*3
  score2=[0]*3
  for j in range(3):
    for k in range(3):
      if j==2 and k==0:
        continue
      dp2[k]+=dp[j]
      dp2[k]%=mod
      if k<=j:
        score2[k]+=score[j]
      elif k==1 and j==0:
        score2[k]+=score[j]*(i-1)
      elif k==2 and j==1:
        score2[k]+=score[j]*i
      else:
        w=score[j]*i
        w%=mod
        w*=i-1
        w%=mod
        score2[k]+=w
      score[k]%=mod
  dp=dp2
  score=score2
  if i%2==0:
    result*=score[0]
    result%=mod
print(result)
0