# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
852140 |
2023-09-21T10:02:44 Z |
overwatch9 |
Burza (COCI16_burza) |
C++17 |
|
1000 ms |
860 KB |
#include <iostream>
#include <vector>
using namespace std;
int n, k;
vector <vector <int>> adj;
vector <int> depth;
const int maxn = 400 + 1;
bool dp[maxn][maxn];
bool ready[maxn][maxn];
void get_depth(int s, int p, int d) {
depth[s] = d;
if (d == k) {
ready[s][d] = true;
dp[s][d] = false;
return;
}
if (adj[s].size() == 1 && s != p) {
// if we reach this node, then we can win
ready[s][d] = true;
dp[s][d] = true;
return;
}
for (auto i : adj[s]) {
if (i == p)
continue;
get_depth(i, p, d+1);
}
}
bool solve(int s, int p) {
if (ready[s][depth[s]])
return dp[s][depth[s]];
int false_dps = 0;
int true_dps = 0;
for (auto i : adj[s]) {
if (i == p)
continue;
if (solve(i, s))
true_dps++;
else
false_dps++;
}
if (true_dps > 0)
return true;
else if (false_dps == 1)
return true;
return false;
}
int main() {
cin >> n >> k;
adj.resize(n+1);
depth.resize(n+1);
for (int i = 0; i < n-1; i++) {
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
get_depth(1, 1, 0);
if (solve(1, 1))
cout << "DA\n";
else
cout << "NE\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
704 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
138 ms |
544 KB |
Output is correct |
4 |
Execution timed out |
1068 ms |
584 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
143 ms |
752 KB |
Output is correct |
4 |
Execution timed out |
1044 ms |
592 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Incorrect |
277 ms |
752 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
696 KB |
Output is correct |
2 |
Correct |
2 ms |
600 KB |
Output is correct |
3 |
Correct |
149 ms |
760 KB |
Output is correct |
4 |
Execution timed out |
1049 ms |
344 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Incorrect |
278 ms |
760 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
3 ms |
600 KB |
Output is correct |
3 |
Correct |
138 ms |
752 KB |
Output is correct |
4 |
Execution timed out |
1029 ms |
528 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |