結果

問題 No.2668 Trees on Graph Paper
ユーザー askr58askr58
提出日時 2024-03-08 23:46:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 523 bytes
コンパイル時間 2,791 ms
コンパイル使用メモリ 250,368 KB
実行使用メモリ 550,204 KB
最終ジャッジ日時 2024-03-08 23:47:07
合計ジャッジ時間 20,678 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 137 ms
51,048 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 953 ms
330,980 KB
testcase_15 AC 1,437 ms
503,180 KB
testcase_16 AC 728 ms
255,120 KB
testcase_17 AC 72 ms
28,116 KB
testcase_18 AC 1,354 ms
477,320 KB
testcase_19 AC 1,180 ms
411,556 KB
testcase_20 AC 1,263 ms
445,752 KB
testcase_21 AC 1,215 ms
426,164 KB
testcase_22 AC 1,236 ms
435,020 KB
testcase_23 AC 768 ms
276,420 KB
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 MLE -
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 1 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
	ll n,m;
	cin>>n>>m;
	vector<vector<ll>> dp(2*n,vector<ll>(3));
	dp[1][2]=1%m;
	dp[2][1]=1%m;
	dp[2][2]=1%m;
	dp[3][0]=1%m;
	dp[3][1]=2%m;
	dp[3][2]=3%m;
	ll ans=1;
	for(ll i=4;i<2*n;i++){
		dp[i][0]=(dp[i-1][1]+dp[i-1][0])%m;
		dp[i][1]=(dp[i-1][0]*(i-2)%m+dp[i-1][1]+dp[i-1][2])%m;
		dp[i][2]=(dp[i-1][0]*((i-2)*(i-1)%m)+dp[i-1][1]*(i-1)%m+dp[i-1][2])%m;
		if(i&1)ans=ans*dp[i][0]%m;
	}
	for(ll i=1;i<2*n;i++)ans=ans*i%m;
	cout<<ans<<endl;

}
0