Submission #708006

#TimeUsernameProblemLanguageResultExecution timeMemory
708006SamrevBurza (COCI16_burza)C++14
0 / 160
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int t = 1; const ll M = 1e9 + 7; ll mod_add(ll a, ll b){ return ((a%M) + (b %M))%M; } ll mod_mul(ll a, ll b){ return ((a%M)*(b%M))%M; } const ll MAX = 1e18; void dfs(int s, int p , vector<int> adj[] , vector<int> &dp){ int child = 0 , max1 = 0 , max2 = 0; for(auto x: adj[s]){ if(x != p){ child++; dfs(x, s, adj , dp); if(max1 < dp[x]){ max2 = max1; max1 = dp[s]; } else{ max2 = max(dp[x] , max2); } } } if(child <=1){ dp[s] = 0; } else{ dp[s] = 1 + max2; } } void solve(){ int n , k ; cin>>n>>k; vector<int> adj[n+1]; for(int i = 0;i<n ; i++){ int a,b;cin>>a>>b; adj[a].push_back(b); adj[b].push_back(a); } vector<int> dp(n + 1); dfs(1,-1,adj,dp); if(dp[1] < k){ cout<<"DA"; } else{ cout<<"NE"; } } int main(){ // freopen("input.txt" , "r" , stdin); // freopen("output.txt" , "w", stdout); // cin>>t; while(t--){ solve(); } }
#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...