# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674551 | 2022-12-25T06:12:19 Z | Nicolas125841 | Burza (COCI16_burza) | C++14 | 1000 ms | 135220 KB |
#include <bits/stdc++.h> using namespace std; #define YES "DA" #define NO "NE" vector<vector<int>> layers; vector<bitset<400>> coverage; bitset<400> dfs(vector<vector<int>> &mp, int n, int p, int d, int k){ if(layers.size() == d) layers.push_back(vector<int>()); if(d == k){ coverage[n] |= 1; coverage[n] <<= layers[d].size(); } layers[d].push_back(n); for(int v : mp[n]){ if(v != p){ bitset<400> res = dfs(mp, v, n, d+1, k); if(layers.size() > k && d < k) coverage[n] |= res; } } return coverage[n]; } int main(){ cin.tie(NULL)->sync_with_stdio(false); int n, k; cin >> n >> k; vector<vector<int>> mp(n, vector<int>()); coverage = vector<bitset<400>>(n, bitset<400>()); for(int i = 0; i < n-1; i++){ int u, v; cin >> u >> v; mp[--u].push_back(--v); mp[v].push_back(u); } dfs(mp, 0, -1, 0, k); if(layers.size() <= k) cout << YES << "\n"; else{ unordered_set<bitset<400>> cur, prev = {bitset<400>()}; bool g = false; for(int i = 1; i <= k; i++){ for(int v : layers[i]){ for(bitset<400> bs : prev){ if((coverage[v] & bs) == 0){ cur.insert(coverage[v] | bs); if((coverage[v] | bs).count() == layers[k].size()) g = true; } } } swap(cur, prev); cur.clear(); } cout << (g ? YES : NO) << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1103 ms | 135220 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1088 ms | 20680 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1087 ms | 20696 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1087 ms | 110712 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1091 ms | 20728 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1092 ms | 20344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1094 ms | 20688 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1094 ms | 92428 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1087 ms | 130896 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1088 ms | 12216 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |