# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
480856 | 2021-10-18T11:58:39 Z | Victor | Burza (COCI16_burza) | C++17 | 1000 ms | 14860 KB |
#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; int n, k, p[401], md[401]; vi graph[401], s_graph[401]; vi depth_nodes[401]; void dfs(int u, int d) { md[u] = d; trav(v, s_graph[u]) if (v != p[u]) { p[v] = u; dfs(v, d + 1); md[u] = max(md[u], md[v]); if (md[v] >= k) graph[u].pb(v); } if(md[u]>=k)depth_nodes[d].pb(u); } set<vector<bool>> memo[401]; void dp(int depth, vector<bool> blocked) { bool all_blocked = 1; rep(i,0,sz(blocked)) all_blocked &= blocked[i]; if (all_blocked) { cout << "DA" << endl; exit(0); } if(depth>=k)return; if (memo[depth].count(blocked)) return; vector<bool> next; int pos = 0; trav(u, depth_nodes[depth]) { trav(v, graph[u])if(p[u]!=v) next.pb(blocked[pos]); ++pos; } all_blocked = 1; rep(i,0,sz(next)) all_blocked &= next[i]; if (all_blocked) { cout << "DA" << endl; exit(0); } rep(i,0,sz(next)){ if(next[i])continue; next[i]=1; dp(depth+1,next); next[i]=0; } memo[depth].insert(blocked); } 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); } dfs(0, 0); dp(0, vector<bool>(sz(depth_nodes[0]), 0)); cout << "NE" << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 2244 KB | Output is correct |
2 | Execution timed out | 1073 ms | 14644 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1022 ms | 14736 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1059 ms | 14796 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 192 ms | 3904 KB | Output is correct |
2 | Execution timed out | 1068 ms | 14820 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1086 ms | 14860 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1085 ms | 14664 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1076 ms | 14696 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 197 ms | 3952 KB | Output is correct |
2 | Execution timed out | 1052 ms | 14672 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 2124 KB | Output is correct |
2 | Execution timed out | 1050 ms | 14628 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 496 ms | 7508 KB | Output is correct |
2 | Execution timed out | 1037 ms | 14736 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |