# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
242561 |
2020-06-28T08:42:02 Z |
VEGAnn |
Burza (COCI16_burza) |
C++14 |
|
770 ms |
143736 KB |
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define i2 array<int,2>
using namespace std;
const int N = 510;
const int oo = 2e9;
vector<int> g[N];
vector<i2> vc, nw;
int n, k, f[N], ht[N], mx_ht[N], cnt[N], pre[N];
void dfs(int v, int pr){
mx_ht[v] = ht[v];
if (ht[v] == k){
f[v] = oo;
return;
}
for (int u : g[v]){
if (u == pr) continue;
ht[u] = ht[v] + 1;
dfs(u, v);
mx_ht[v] = max(mx_ht[v], mx_ht[u]);
}
if (mx_ht[v] < k){
f[v] = 0;
return;
}
vc.clear();
for (int u : g[v]){
if (u == pr) continue;
if (f[u] > 0)
vc.PB({f[u], u});
}
f[v] = 1;
sort(all(vc));
reverse(all(vc));
for (int it = 1; it < sz(vc); it++){
i2 cur = vc[it];
if (cur[0] == oo) {
f[v] = oo;
break;
}
f[v] += cur[0];
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> k;
for (int i = 1; i < n; i++){
int x, y; cin >> x >> y;
x--; y--;
g[x].PB(y);
g[y].PB(x);
}
dfs(0, -1);
vc.clear();
for (int u : g[0])
if (f[u] > 0)
vc.PB({f[u], u});
bool bad = 0;
for (int it = 0; it < k && sz(vc) > 0; it++){
if (it + 1 == k){
if (sz(vc) > 1)
bad = 1;
break;
}
sort(all(vc));
reverse(all(vc));
nw.clear();
for (int it = 1; it < sz(vc); it++){
int v = vc[it][1];
for (int u : g[v]){
if (u == pre[v]) continue;
if (f[u] > 0)
nw.PB({f[u], u});
}
}
vc = nw;
}
cout << (!bad ? "DA\n" : "NE\n");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
892 KB |
Output is correct |
2 |
Correct |
22 ms |
4040 KB |
Output is correct |
3 |
Incorrect |
162 ms |
32668 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
4044 KB |
Output is correct |
2 |
Correct |
21 ms |
4044 KB |
Output is correct |
3 |
Incorrect |
392 ms |
72904 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
4036 KB |
Output is correct |
2 |
Correct |
21 ms |
4036 KB |
Output is correct |
3 |
Incorrect |
554 ms |
100872 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1276 KB |
Output is correct |
2 |
Correct |
22 ms |
4044 KB |
Output is correct |
3 |
Incorrect |
361 ms |
68988 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
4044 KB |
Output is correct |
2 |
Correct |
23 ms |
4284 KB |
Output is correct |
3 |
Incorrect |
97 ms |
19388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
4160 KB |
Output is correct |
2 |
Correct |
22 ms |
4044 KB |
Output is correct |
3 |
Incorrect |
490 ms |
90280 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
4164 KB |
Output is correct |
2 |
Correct |
21 ms |
4044 KB |
Output is correct |
3 |
Incorrect |
770 ms |
143736 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1276 KB |
Output is correct |
2 |
Correct |
21 ms |
4044 KB |
Output is correct |
3 |
Incorrect |
184 ms |
35332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
896 KB |
Output is correct |
2 |
Correct |
22 ms |
4152 KB |
Output is correct |
3 |
Incorrect |
336 ms |
62892 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
2124 KB |
Output is correct |
2 |
Correct |
22 ms |
4160 KB |
Output is correct |
3 |
Incorrect |
98 ms |
19440 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |