Submission #967314

# Submission time Handle Problem Language Result Execution time Memory
967314 2024-04-21T20:21:22 Z blackslex Burza (COCI16_burza) C++17
0 / 160
1 ms 432 KB
#include<bits/stdc++.h>

using namespace std;

int n, k, x, y;

int main() {
    scanf("%d %d", &n, &k);
    vector<vector<int>> v(n + 5, vector<int>());
    for (int i = 1; i < n; i++) scanf("%d %d", &x, &y), v[x].emplace_back(y), v[y].emplace_back(x);
    vector<int> dp(n + 5);
    function<void(int, int)> dfs = [&] (int cur, int par) {
        bool isleaf = 1;
        vector<int> u;
        for (auto &e: v[cur]) {
            if (par == e) continue; isleaf = 0;
            dfs(e, cur); u.emplace_back(dp[e]);
        }
        sort(u.rbegin(), u.rend());
        if (u.size() >= 2) dp[cur] = u[1] + 1;
    };
    dfs(1, 0);
    printf("%s", dp[1] >= k ? "NE" : "DA");
}

Compilation message

burza.cpp: In lambda function:
burza.cpp:16:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |             if (par == e) continue; isleaf = 0;
      |             ^~
burza.cpp:16:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |             if (par == e) continue; isleaf = 0;
      |                                     ^~~~~~
burza.cpp:13:14: warning: variable 'isleaf' set but not used [-Wunused-but-set-variable]
   13 |         bool isleaf = 1;
      |              ^~~~~~
burza.cpp: In function 'int main()':
burza.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
burza.cpp:10:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for (int i = 1; i < n; i++) scanf("%d %d", &x, &y), v[x].emplace_back(y), v[y].emplace_back(x);
      |                                 ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -