Submission #480878

#TimeUsernameProblemLanguageResultExecution timeMemory
480878VictorBurza (COCI16_burza)C++17
160 / 160
217 ms6984 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 graph[401]; int n, k; uset<int> dp(int u, int d, int p) { uset<int> ret; if (d == k) { ret.insert(1 << d); //cout << "u = " << u + 1 << " d = " << d << " sols = " << sz(ret) << endl; return ret; } ret.insert(0); trav(v, graph[u]) if (v != p) { uset<int> vals = dp(v, d + 1, u); uset<int> nxt; trav(v1, ret) trav(v2, vals) if ((v1 & v2) == 0) nxt.insert(v1 | v2); ret.swap(nxt); } ret.insert(1 << d); //cout << "u = " << u + 1 << " d = " << d << " sols = " << sz(ret) << endl; return ret; } 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; graph[--u].pb(--v); graph[v].pb(u); } if (k * k + 1 >= n) { cout << "DA" << endl; return 0; } auto s = dp(0, 0, 0); if (sz(s) > 1) cout << "DA" << endl; else cout << "NE" << 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...