Submission #687856

# Submission time Handle Problem Language Result Execution time Memory
687856 2023-01-27T02:58:11 Z 2vas Burza (COCI16_burza) C++17
0 / 160
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t=1; // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

int n, k;
const int MXN = 400;
vector<int> edges[MXN];

bool dfs(int i, int parent, int depth) {
    if (depth >= k) return false;

    bool alreadyChildFalse = false;
    for (int v : edges[i]) {
        if (v == parent) continue;
        if (dfs(v, i, depth+1)) continue;

        if (alreadyChildFalse) return false;
        alreadyChildFalse = true;
    }

    return true;
}

void solve() {    
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int x, y; cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    if (dfs(0, -1, 0)) {
        cout << "DA" << endl;
    } else {
        cout << "NE" << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 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 336 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 340 KB Output isn't correct
2 Halted 0 ms 0 KB -