# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
146239 |
2019-08-23T01:47:56 Z |
letrongdat |
Burza (COCI16_burza) |
C++17 |
|
3 ms |
1020 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define repn(i, a, b) for(int i=a; i < b; ++i)
const int INF = 0x3f3f3f3f;
const int N = 410;
int n, k;
int w[N][N];
vector<int> e[N];
int dfs(int u, int re, int prv = 0) {
if (w[u][re] != -1) return w[u][re];
int &ans = w[u][re];
ans = INF;
if (re == 0) {
if (e[u].size() < 2) return ans = 0;
return ans;
}
if (u == 1) {
if (e[u].size() < 1) return ans = 0;
} else if (e[u].size() < 3) return ans = 0;
multiset < int > ms;
for(auto v: e[u]) if (v != prv)
ms.insert(dfs(v, re -1, u));
for(auto v: e[u]) if (v != prv) {
ms.erase(ms.find(w[v][re-1]));
ans = min(ans, *ms.crbegin() + 1);
ms.insert(w[v][re-1]);
}
return ans;
}
int main() {
ios::sync_with_stdio(0);
cin >> n >> k;
repn(i, 1, n) {
int u, v;
cin >> u >> v;
e[u].pb(v);
e[v].pb(u);
}
memset(w, -1, sizeof w);
cout << (dfs(1, k) < k ? "DA" : "NE");
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |