# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
582838 |
2022-06-24T13:46:02 Z |
Neos |
Burza (COCI16_burza) |
C++14 |
|
93 ms |
12576 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using ii = pair<int, int>;
#define fastIO ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
template<class X, class Y>
bool minimize(X &x, const Y &y) {
X eps = 1e-9;
if (x > y + eps) {
x = y;
return true;
} else return false;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
X eps = 1e-9;
if (x + eps < y) {
x = y;
return true;
} else return false;
}
const int N = 4e2 + 7, oo = 1e9 + 7;
int n, k, m, timer, ans, l[N], r[N], dp[N][1 << 20];
vector<int> adj[N];
void euler(int u, int par = -1, int depth = 1) {
if (depth == k) {
l[u] = r[u] = ++timer;
return;
}
for (int v: adj[u]) if (v != par) {
euler(v, u, depth + 1);
maximize(r[u], r[v]);
minimize(l[u], l[v]);
}
}
void dfs(int u, int par = -1, int depth = 1) {
if (depth >= k) return;
for (int v: adj[u]) if (v != par) {
dfs(v, u, depth + 1);
if (l[v] == oo) continue;
for (int i = 0; i < (1 << k); i++) if (!getBit(i, depth))
dp[r[v]][i | (1 << depth)] |= dp[l[v] - 1][i];
}
}
signed main() {
fastIO;
//#ifndef ONLINE_JUDGE
// freopen("test.inp", "r", stdin);
// freopen("test.out", "w", stdout);
//#endif
cin >> n >> k;
if (k * k >= n) { cout << "DA\n"; return 0; }
for (int i = 0; i < (1 << k); i++) dp[0][i] = 1;
for (int i = 1; i <= n; i++) l[i] = oo, r[i] = 0;
for (int i = 0, u, v; i < n - 1; i++) {
cin >> u >> v;
adj[u].pb(v); adj[v].pb(u);
} euler(1), dfs(1);
// cerr << dp[timer][(1 << m) - 1] << endl;
cout << (!dp[timer][(1 << k) - 1] ? "NE" : "DA");
}
/*
dp[i][mask] = can you "block out" of the first i "depth-k" nodes just blocking nodes have depth in "mask"
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1876 KB |
Output is correct |
2 |
Correct |
86 ms |
11552 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
10496 KB |
Output is correct |
2 |
Correct |
84 ms |
11024 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
89 ms |
12092 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
11288 KB |
Output is correct |
2 |
Correct |
86 ms |
10672 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
3412 KB |
Output is correct |
2 |
Correct |
80 ms |
11448 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
10548 KB |
Output is correct |
2 |
Correct |
93 ms |
11828 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
848 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
10256 KB |
Output is correct |
2 |
Correct |
85 ms |
11072 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
852 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
12576 KB |
Output is correct |
2 |
Correct |
86 ms |
11816 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
82 ms |
12160 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2960 KB |
Output is correct |
2 |
Correct |
90 ms |
11644 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1620 KB |
Output is correct |
2 |
Correct |
86 ms |
11076 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
2 ms |
596 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
5684 KB |
Output is correct |
2 |
Correct |
89 ms |
12092 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
39 ms |
5828 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |