Submission #708253

#TimeUsernameProblemLanguageResultExecution timeMemory
708253VladPislaruBurza (COCI16_burza)C++17
0 / 160
3 ms596 KiB
#include <bits/stdc++.h> using namespace std; int n, k; vector <int> adj[405]; int dp[405]; /// dp[i] = nr minim de mutari daca avem coin-ul in i int DFS(int nod, int father) { int maxim1 = 0, maxim2 = 0; for (int i : adj[nod]) { if (i != father) DFS(i, nod); if (dp[i] > maxim1) { maxim2 = maxim1; maxim1 = dp[i]; } else if (dp[i] > maxim2) { maxim2 = maxim1; maxim1 = dp[i]; } } if (nod != 1 && adj[nod].size() <= 2) dp[nod] = 0; else dp[nod] = maxim2 + 1; } int main() { cin >> n >> k; for (int i = 1; i < n; i++) { int x, y; cin >> x >> y; adj[x].push_back(y); adj[y].push_back(x); } DFS(1, 0); ///cout << dp[1] << "\n"; if (dp[1] < k) cout << "DA\n"; else cout << "NE\n"; return 0; }

Compilation message (stderr)

burza.cpp: In function 'int DFS(int, int)':
burza.cpp:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
   28 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...