結果

問題 No.140 みんなで旅行
ユーザー sugim48sugim48
提出日時 2015-01-30 00:34:07
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,402 bytes
コンパイル時間 1,153 ms
コンパイル使用メモリ 93,892 KB
実行使用メモリ 30,076 KB
最終ジャッジ日時 2023-09-05 08:14:17
合計ジャッジ時間 10,410 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
25,760 KB
testcase_01 AC 51 ms
25,696 KB
testcase_02 AC 1,590 ms
25,764 KB
testcase_03 AC 24 ms
25,872 KB
testcase_04 AC 61 ms
25,732 KB
testcase_05 AC 74 ms
25,792 KB
testcase_06 AC 89 ms
25,692 KB
testcase_07 AC 100 ms
25,748 KB
testcase_08 AC 111 ms
25,688 KB
testcase_09 AC 124 ms
25,692 KB
testcase_10 AC 135 ms
25,880 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { ll B, T, F, P; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 10;

int main() {
	int N; cin >> N;
	vector< vector<ll> > dp(1200, vector<ll>(1200));
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		vector< vector<ll> > _dp(1200, vector<ll>(1200));
		for (int i = 0; i < 1200; i++)
			for (int j = 0; j < 1200; j++) {
				ll& x = dp[i][j];
				if (x == 0) continue;
				_dp[i][j] = (_dp[i][j] + x * i + x * (i + j) * (i + j - 1)) % MOD;
				if (j) _dp[i + 1][j - 1] = (_dp[i + 1][j - 1] + x * j) % MOD;
				_dp[i + 1][j] = (_dp[i + 1][j] + x) % MOD;
				_dp[i][j + 1] = (_dp[i][j + 1] + x * i * 2 + x * j * 2) % MOD;
				_dp[i][j + 2] = (_dp[i][j + 2] + x) % MOD;
			}
		dp = _dp;
	}
	ll ans = 0;
	for (int i = 1; i < 1200; i++)
		ans = (ans + dp[i][0]) % MOD;
	cout << ans << endl;
}
0