# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
394226 |
2021-04-26T07:45:20 Z |
haskaran |
Burza (COCI16_burza) |
C++17 |
|
1 ms |
332 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 410;
int n, k, dp[N];
bool flag;
vector<int> adj[N];
void dfs(int v = 0, int par = -1) {
int cnt = 0;
vector<int> vec;
for (int u: adj[v])
if (u ^ par)
dfs(u, v), vec.push_back(dp[u]);
sort(vec.begin(), vec.end(), greater<int>());
for (int x: vec)
if (x + 1 >= k)
cnt++;
if (cnt > 2 && !v)
flag = true;
if (vec.size() < 2)
dp[v] = 0;
else
dp[v] = vec[1] + 1;
}
int main() {
ios:: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
cin >> n >> k;
for (int i = 1, u, v; i < n; i++)
cin >> u >> v, adj[--u].push_back(--v), adj[v].push_back(u);
dfs();
if (dp[0] >= k || flag)
cout << "NE\n";
else
cout << "DA\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |