結果
問題 | No.196 典型DP (1) |
ユーザー | akusyounin2412 |
提出日時 | 2019-02-05 23:53:35 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 2,729 bytes |
コンパイル時間 | 1,532 ms |
コンパイル使用メモリ | 131,664 KB |
実行使用メモリ | 27,648 KB |
最終ジャッジ日時 | 2024-06-10 23:19:58 |
合計ジャッジ時間 | 4,348 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 4 ms
5,376 KB |
testcase_16 | AC | 10 ms
6,528 KB |
testcase_17 | AC | 18 ms
7,936 KB |
testcase_18 | AC | 29 ms
9,728 KB |
testcase_19 | AC | 36 ms
10,624 KB |
testcase_20 | AC | 50 ms
11,904 KB |
testcase_21 | AC | 49 ms
12,032 KB |
testcase_22 | AC | 49 ms
12,032 KB |
testcase_23 | AC | 50 ms
17,408 KB |
testcase_24 | AC | 52 ms
15,744 KB |
testcase_25 | AC | 52 ms
15,360 KB |
testcase_26 | AC | 39 ms
27,648 KB |
testcase_27 | AC | 37 ms
27,648 KB |
testcase_28 | AC | 38 ms
27,648 KB |
testcase_29 | AC | 38 ms
27,520 KB |
testcase_30 | AC | 38 ms
27,648 KB |
testcase_31 | AC | 95 ms
11,648 KB |
testcase_32 | AC | 95 ms
11,648 KB |
testcase_33 | AC | 97 ms
11,648 KB |
testcase_34 | AC | 97 ms
11,648 KB |
testcase_35 | AC | 97 ms
11,776 KB |
testcase_36 | AC | 91 ms
11,776 KB |
testcase_37 | AC | 52 ms
11,776 KB |
testcase_38 | AC | 92 ms
11,648 KB |
testcase_39 | AC | 85 ms
11,648 KB |
testcase_40 | AC | 97 ms
11,648 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
ソースコード
# include <iostream> # include <algorithm> #include <array> # include <cassert> #include <cctype> #include <climits> #include <numeric> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <tuple> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> # include <chrono> # include <random> # include <limits.h> # include <unordered_map> # include <unordered_set> # include <deque> # include <cstdio> # include <cstring> #include <stdio.h> #include<time.h> #include <stdlib.h> #include <cstdint> #include <cfenv> #include<fstream> //#include <bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; long long MOD = 1000000000 + 7; //924844033 1000000000 + 9; constexpr long long INF = numeric_limits<LL>::max(); const double PI = acos(-1); #define fir first #define sec second #define thi third #define debug(x) cerr<<#x<<": "<<x<<'\n' typedef pair<LL, LL> Pll; typedef pair<double, double> Dll; typedef pair<LL, pair<LL, LL>> Ppll; typedef pair<LL, pair<LL, bitset<100001>>> Pbll; typedef pair<LL, pair<LL, vector<LL>>> Pvll; typedef pair<LL, LL> Vec2; struct Tll { LL first, second, third; }; struct Fll { LL first, second, third, fourth; }; typedef pair<LL, Tll> Ptll; #define rep(i,rept) for(LL i=0;i<rept;i++) #define Rrep(i,mf) for(LL i=mf-1;i>=0;i--) LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[3000][3000], a[330020], b[330000],sub[3000]; string str, ss; bool f[220000]; char c[4000][4000]; int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } }; struct Edge { LL to, cost; }; struct edge { LL from, to, cost; }; vector<vector<Edge>>vec,rvec; vector<edge>ed; vector<LL>v; map<string, LL>ma; set<LL>st; void YN(bool f) { if (f) cout << "YES" << endl; else cout << "NO" << endl; } void yn(bool f) { if (f) cout << "Yes" << endl; else cout << "No" << endl; } void sub_cnt(int cur,int par) { rep(i, vec[cur].size()) { if (vec[cur][i].to == par)continue; sub_cnt(vec[cur][i].to, cur); sub[cur] += sub[vec[cur][i].to]; } sub[cur]++; } void dfs(int cur,int par) { rep(i, vec[cur].size()) { LL v = vec[cur][i].to; if (v == par)continue; dfs(v,cur); vector<LL>table(sub[cur]+1, 0); rep(j, sub[cur] - sub[v]) rep(l, sub[v] + 1) (table[j + l] += dp[cur][j] * dp[v][l]) %= MOD; rep(j, sub[cur])dp[cur][j] = table[j]; } dp[cur][sub[cur]] = 1; } int main() { cin >> n >> k; vec.resize(n); rep(i, n-1) { LL x, y; cin >> x >> y; vec[x].push_back(Edge{ y,0 }); vec[y].push_back(Edge{ x,0 }); } sub_cnt(0, -1); rep(i, n)dp[i][0] = 1; dfs(0,-1); cout << dp[0][k] << endl; return 0; }