제출 #480858

#제출 시각아이디문제언어결과실행 시간메모리
480858VictorBurza (COCI16_burza)C++17
0 / 160
1095 ms23936 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define per(i, a, b) for (int i = (b - 1); i >= (a); --i) #define trav(a, x) for (auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define debug(x) cout << #x << " = " << x << endl #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<pll> vpll; const int INF = 1'000'000'007; vi s_graph[401], graph[401]; int n, k, md[401], p[401]; void dfs(int u, int d) { md[u] = d; if (d < k) trav(v, s_graph[u]) if (p[u] != v) { p[v] = u; dfs(v, d + 1); md[u] = max(md[u], md[v]); if (md[v] == k) graph[u].pb(v); } } uset<string> dp(int u, int d) { uset<string> sols; if (sz(graph[u])) sols.insert(string(401, '0')); trav(v, graph[u]) if (v != p[u]) { uset<string> vec = dp(v, d + 1); uset<string> nxt; trav(sol, sols) { bitset<401> sol_bs = bitset<401>(sol); trav(bs, vec) if (!(sol_bs & bitset<401>(bs)).count()) nxt.insert((sol_bs | bitset<401>(bs)).to_string()); } sols.swap(nxt); } string bs(401, '0'); bs[d] = '1'; sols.insert(bs); // cout<<"u = "<<u<<" d = "<<d<<" num sol = "<<sz(sols)<<endl; // set<bitset<401>>sols; return sols; } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cin >> n >> k; rep(i, 0, n - 1) { int u, v; cin >> u >> v; s_graph[--u].pb(--v); s_graph[v].pb(u); } p[0] = 0; dfs(0, 0); if(sz(dp(0,0))<=1)cout<<"NE"<<endl; else cout<<"DA"<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...