# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1024077 |
2024-07-15T11:28:28 Z |
caterpillow |
Burza (COCI16_burza) |
C++17 |
|
556 ms |
410708 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
#define vt vector
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()
#define size(x) ((int) (x).size())
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0R(i, b) FOR (i, 0, b)
#define endl '\n'
const ll INF = 1e18;
const int inf = 1e9;
#define char unsigned char
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
int n, k, t;
vt<vt<int>> adj;
vt<int> depth, pos, jump, rpos;
vt<char> val;
void dfs(int u, int p = -1) {
pos[u] = t++;
if (depth[u] == k) val[u] = 1;
for (int v : adj[u]) {
if (v == p) continue;
depth[v] = depth[u] + 1;
dfs(v, u);
val[u] += val[v];
}
jump[u] = t;
}
const int mxk = 20;
char dp[401][1 << mxk];
main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k;
if (k * k >= n) {
cout << "DA\n";
return 0;
}
adj.resize(n);
depth = pos = jump = rpos = vt<int>(n, 0);
val.resize(n);
F0R (i, n - 1) {
int u, v; cin >> u >> v;
u--, v--;
adj[u].pb(v);
adj[v].pb(u);
}
dfs(0);
F0R (i, n) rpos[pos[i]] = i;
ROF (i, 0, n) {
int u = rpos[i];
F0R (msk, 1 << mxk) {
dp[i][msk] = dp[i + 1][msk];
if (depth[u] <= k && 1 & (msk >> depth[u])) dp[i][msk] = max(dp[i][msk], (char) (val[u] + dp[jump[u]][msk ^ (1 << depth[u])]));
}
}
if (dp[0][(1 << mxk) - 2] == val[0]) cout << "DA\n";
else cout << "NE\n";
}
Compilation message
burza.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
46 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
350 ms |
320396 KB |
Output is correct |
2 |
Correct |
489 ms |
410708 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
511 ms |
393376 KB |
Output is correct |
6 |
Correct |
111 ms |
93780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
498 ms |
390232 KB |
Output is correct |
2 |
Correct |
556 ms |
392312 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
522 ms |
397412 KB |
Output is correct |
6 |
Incorrect |
503 ms |
406604 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
501 ms |
395344 KB |
Output is correct |
2 |
Correct |
521 ms |
395316 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
386 ms |
318308 KB |
Output is correct |
6 |
Correct |
114 ms |
100944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
481 ms |
386200 KB |
Output is correct |
2 |
Correct |
527 ms |
410704 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
336 ms |
273244 KB |
Output is correct |
6 |
Correct |
99 ms |
83556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
473 ms |
377984 KB |
Output is correct |
2 |
Correct |
475 ms |
390224 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
473 ms |
394324 KB |
Output is correct |
6 |
Correct |
320 ms |
278344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
485 ms |
393384 KB |
Output is correct |
2 |
Correct |
500 ms |
387184 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
389 ms |
364572 KB |
Output is correct |
6 |
Correct |
300 ms |
245588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
477 ms |
400500 KB |
Output is correct |
2 |
Correct |
480 ms |
389204 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
499 ms |
390228 KB |
Output is correct |
6 |
Correct |
381 ms |
322632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
413 ms |
345020 KB |
Output is correct |
2 |
Correct |
487 ms |
402512 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
319 ms |
245580 KB |
Output is correct |
6 |
Correct |
424 ms |
400464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
286548 KB |
Output is correct |
2 |
Correct |
454 ms |
406608 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
242 ms |
247664 KB |
Output is correct |
6 |
Correct |
386 ms |
368724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
363 ms |
340944 KB |
Output is correct |
2 |
Correct |
461 ms |
405844 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
367 ms |
345024 KB |
Output is correct |
6 |
Correct |
178 ms |
175696 KB |
Output is correct |