# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782380 | 2023-07-13T21:36:35 Z | vgoofficial | Burza (COCI16_burza) | C++14 | 1000 ms | 524288 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; int n,k; vector<vector<int>> edges; vector<int> depth; vector<int> parents; vector<vector<int>> depths(400); int maxDepth(int i, int dpth) { depth[i]=dpth; int maxD = dpth; for(int j = 0; j < edges[i].size(); j++) { int l = edges[i][j]; if(depth[l]!=-1) continue; if(dpth==k) { edges[i][j]=-1; } else { if(maxDepth(l, dpth+1)!=k) { edges[i][j]=-1; } else { parents[l]=i; maxD=k; } } } if(maxD==k) { depths[dpth].push_back(i); } return maxD; } struct state { int level; vector<bool> unaccessible; state(int level, vector<bool> unaccessible) { this->unaccessible = unaccessible; this->level = level; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; if(k * k>n) { cout << "DA" << endl; return 0; } edges=vector<vector<int>>(n); depth=vector<int>(n, -1); parents=vector<int>(n, -1); depth[0]=0; for(int i = 1; i < n; i++) { int a,b; cin >> a >> b; edges[a-1].push_back(b-1); edges[b-1].push_back(a-1); } maxDepth(0, 0); /* for(int i = 0; i < n; i++) { cout << i << " " << depth[i] << " " << parents[i] << endl; for(int j: depths[i]) { cout << j << " "; } cout << endl; for(int j: edges[i]) { cout << j << " "; } cout << endl; } */ deque<state> q; q.push_back(state(1, vector<bool>(n))); while(q.size()) { state s = q.front(); q.pop_front(); int notDone = 0; for(int in: depths[s.level]) { if(s.unaccessible[parents[in]]) { s.unaccessible[in]=true; } else { s.unaccessible[in]=false; notDone++; } } if(notDone<2) { cout << "DA" << endl; return 0; } if(s.level==k) continue; for(int i: depths[s.level]) { if(!s.unaccessible[i]) { s.unaccessible[i]=true; q.push_back(state(s.level+1, s.unaccessible)); s.unaccessible[i]=false; } } } cout << "NE" << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1099 ms | 420756 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 425224 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 490 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1088 ms | 507172 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 960 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1099 ms | 476276 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 542 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 654 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 861 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 602 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |