結果

問題 No.2668 Trees on Graph Paper
ユーザー shobonvipshobonvip
提出日時 2024-03-08 22:59:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,545 bytes
コンパイル時間 4,860 ms
コンパイル使用メモリ 266,440 KB
実行使用メモリ 550,096 KB
最終ジャッジ日時 2024-03-08 22:59:27
合計ジャッジ時間 20,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 122 ms
50,940 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 880 ms
330,872 KB
testcase_15 AC 1,256 ms
503,072 KB
testcase_16 AC 659 ms
255,012 KB
testcase_17 AC 65 ms
28,008 KB
testcase_18 AC 1,186 ms
477,212 KB
testcase_19 AC 1,045 ms
411,448 KB
testcase_20 AC 1,186 ms
445,644 KB
testcase_21 AC 1,082 ms
426,056 KB
testcase_22 AC 1,101 ms
434,912 KB
testcase_23 AC 736 ms
276,312 KB
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 MLE -
testcase_28 AC 2 ms
6,548 KB
testcase_29 AC 2 ms
6,548 KB
testcase_30 AC 2 ms
6,548 KB
testcase_31 AC 2 ms
6,548 KB
testcase_32 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m; cin >> n >> m;
	mint::set_mod(m);

	
	vector dp(2*n + 5, vector<mint>(3));
	dp[0][0] = 1;
	rep(i,0,2*n+4){
		rep(j,0,3){
			if (j-1 >= 0){
				dp[i+1][j-1] += mint(i+1) * dp[i][j];
			}
			dp[i+1][j] += dp[i][j];
			if (j+1 < 3){
				dp[i+1][j+1] += dp[i][j];
			}
			if (j+2 < 3){
				dp[i+1][j+2] += dp[i][j];
			}
		}
	}
	
	mint ans = 1;
	rep(i,1,2*n){
		ans *= i;
	}
	rep(i,1,n){
		ans *= dp[2*i-1][2];
	}
	cout << ans.val() << '\n';
}

0