# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
229253 |
2020-05-03T23:29:58 Z |
MetB |
Burza (COCI16_burza) |
C++14 |
|
171 ms |
25208 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define N 1000003
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;
int n, k, ptr;
bitset <1 << 21> d[401];
vector <int> g[N];
vector < pair <int, int> > v[401];
pair <int, int> dfs (int x, int p, int h) {
if (h == k) {
v[++ptr].push_back ({ptr, h - 1});
//cout << "leaf " << x << ' ' << ptr << endl;
return {ptr, ptr};
}
int l = 0, r = 0;
for (int to : g[x]) {
if (to != p) {
auto a = dfs (to, x, h + 1);
if (!l) l = a.first;
r = a.second;
}
}
//cout << x << ' ' << l << ' ' << r << endl;
if (h && l) v[r].push_back ({l, h - 1});
return {l, r};
}
int main () {
cin >> n >> k;
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
a--, b--;
g[a].push_back (b);
g[b].push_back (a);
}
if (k * k >= n) {
cout << "DA";
return 0;
}
dfs (0, -1, 0);
d[0][0] = 1;
for (int i = 1; i <= ptr; i++) {
for (int j = 1; j < (1 << k); j++) {
for (auto a : v[i]) {
if (j & (1 << a.second)) {
d[i][j] = (d[i][j] | d[a.first - 1][j - (1 << a.second)]);
}
}
}
}
for (int j = 0; j < (1 << k); j++)
if (d[ptr][j]) {
cout << "DA";
return 0;
}
cout << "NE";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
24576 KB |
Output is correct |
2 |
Correct |
155 ms |
25184 KB |
Output is correct |
3 |
Correct |
18 ms |
23808 KB |
Output is correct |
4 |
Correct |
18 ms |
23808 KB |
Output is correct |
5 |
Correct |
19 ms |
24832 KB |
Output is correct |
6 |
Incorrect |
17 ms |
23936 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
24952 KB |
Output is correct |
2 |
Correct |
138 ms |
24952 KB |
Output is correct |
3 |
Correct |
20 ms |
23936 KB |
Output is correct |
4 |
Correct |
18 ms |
23808 KB |
Output is correct |
5 |
Correct |
137 ms |
24956 KB |
Output is correct |
6 |
Incorrect |
19 ms |
25088 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
24928 KB |
Output is correct |
2 |
Correct |
145 ms |
25080 KB |
Output is correct |
3 |
Correct |
17 ms |
23808 KB |
Output is correct |
4 |
Correct |
18 ms |
23808 KB |
Output is correct |
5 |
Incorrect |
18 ms |
24576 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
24428 KB |
Output is correct |
2 |
Correct |
144 ms |
25208 KB |
Output is correct |
3 |
Correct |
19 ms |
23808 KB |
Output is correct |
4 |
Correct |
18 ms |
23880 KB |
Output is correct |
5 |
Correct |
18 ms |
24448 KB |
Output is correct |
6 |
Incorrect |
18 ms |
23936 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
24856 KB |
Output is correct |
2 |
Correct |
158 ms |
24956 KB |
Output is correct |
3 |
Correct |
17 ms |
23808 KB |
Output is correct |
4 |
Correct |
20 ms |
23808 KB |
Output is correct |
5 |
Incorrect |
18 ms |
24832 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
25080 KB |
Output is correct |
2 |
Correct |
148 ms |
24828 KB |
Output is correct |
3 |
Correct |
18 ms |
23808 KB |
Output is correct |
4 |
Correct |
19 ms |
23808 KB |
Output is correct |
5 |
Incorrect |
19 ms |
24960 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
25056 KB |
Output is correct |
2 |
Correct |
148 ms |
24952 KB |
Output is correct |
3 |
Correct |
18 ms |
23808 KB |
Output is correct |
4 |
Correct |
19 ms |
23808 KB |
Output is correct |
5 |
Incorrect |
146 ms |
24932 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
24320 KB |
Output is correct |
2 |
Correct |
154 ms |
25084 KB |
Output is correct |
3 |
Correct |
18 ms |
23808 KB |
Output is correct |
4 |
Correct |
18 ms |
23808 KB |
Output is correct |
5 |
Incorrect |
18 ms |
24448 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
24392 KB |
Output is correct |
2 |
Correct |
131 ms |
25036 KB |
Output is correct |
3 |
Correct |
18 ms |
23808 KB |
Output is correct |
4 |
Correct |
17 ms |
23808 KB |
Output is correct |
5 |
Correct |
18 ms |
24448 KB |
Output is correct |
6 |
Correct |
19 ms |
24832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
24416 KB |
Output is correct |
2 |
Correct |
171 ms |
25080 KB |
Output is correct |
3 |
Correct |
18 ms |
23808 KB |
Output is correct |
4 |
Correct |
18 ms |
23808 KB |
Output is correct |
5 |
Incorrect |
74 ms |
24440 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |