Submission #165770

#TimeUsernameProblemLanguageResultExecution timeMemory
165770_qVp_Burza (COCI16_burza)C++14
160 / 160
105 ms3272 KiB
#include <bits/stdc++.h> using namespace std; const int md = 410; int n, k, r = 1; vector <int> adj[md], v[md]; int start[md], finish[md], depth[md]; bool f[md][(1 << 20) + 5]; void dfs(int u, int par) { if (depth[u] == k - 1) { start[u] = r++; finish[u] = r; return ; } start[u] = r; for (int i = 0; i < adj[u].size(); i++) { int v = adj[u][i]; if (v == par) continue; depth[v] = depth[u] + 1; dfs(v, u); } finish[u] = r; } int getbit(int x, int i) { return ((x >> i) & 1); } int onbit(int x, int i) { return (x | (1 << i)); } bool check() { f[1][0] = 1; //cout << r << endl; for(int i = 2; i <= n; i++) { v[start[i]].push_back(i); //cout << i << " " << start[i] << " " << finish[i] << " " << depth[i] << endl; } //return 0; for(int i = 1; i <= r; i++) for(int mask = 0; mask < (1 << k); mask++) { if (!f[i][mask]) continue; for(int t = 0; t < v[i].size(); t++) { int x = v[i][t]; if (!getbit(mask, depth[x])) f[finish[x]][onbit(mask, depth[x])] = 1; } } //return 0; for(int mask = 0; mask < (1 << k); mask++) if (f[r][mask]) return true; return false; } int main() { //freopen("test.in", "r", stdin); ios_base::sync_with_stdio(0); cin >> n >> k; if (k * k >= n) { cout << "DA"; return 0; } for(int i = 1; i < n; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } depth[1] = -1; dfs(1, 0); //return 0; cout << (check() ? "DA" : "NE"); return 0; }

Compilation message (stderr)

burza.cpp: In function 'void dfs(int, int)':
burza.cpp:19:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < adj[u].size(); i++) {
                     ~~^~~~~~~~~~~~~~~
burza.cpp: In function 'bool check()':
burza.cpp:47:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int t = 0; t < v[i].size(); t++) {
                            ~~^~~~~~~~~~~~~
#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...