結果

問題 No.196 典型DP (1)
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-26 22:50:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 1,668 ms
コンパイル使用メモリ 146,660 KB
実行使用メモリ 49,144 KB
最終ジャッジ日時 2023-09-18 12:20:36
合計ジャッジ時間 3,289 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 12 ms
48,840 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 34 ms
48,852 KB
testcase_32 AC 34 ms
48,984 KB
testcase_33 AC 34 ms
48,812 KB
testcase_34 AC 34 ms
48,812 KB
testcase_35 AC 34 ms
48,824 KB
testcase_36 AC 32 ms
48,828 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<int> es[3000];
long long dp[3000][3000];
int child[3000];

long long mod = 1000000007;

int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		es[a].push_back(b);
	}
	for (int i = N - 1; i >= 0; i--)
	{
		child[i] = 1;
		dp[i][0] = 1;
		for (auto j : es[i]){
			for (int k = child[i] - 1; k >= 0; k--)
			{
				for (int l = child[j]; l >= 1; l--)
				{
					dp[i][k + l] += dp[i][k] * dp[j][l];
					dp[i][k + l] %= mod;
				}
			}
			child[i] += child[j];
		}
		dp[i][child[i]] = 1;
	}


	cout << dp[0][K] << endl;
	cin >> N;
}
0