Submission #964117

#TimeUsernameProblemLanguageResultExecution timeMemory
964117Batorgil952Burza (COCI16_burza)C++14
0 / 160
1 ms600 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int N=402; vector< int > v[N]; int dp[N]; bool B[N]; void DFS(int p){ int un, vn; vector< int > u; vn=v[p].size(); for(int i=0; i<vn; i++){ if(!B[v[p][i]]){ B[v[p][i]]=true; DFS(v[p][i]); u.pb(dp[v[p][i]]); } } un=u.size(); if(un==0 || un==1) dp[p]=1; else{ sort(u.begin(), u.end()); dp[p]=u[un-2]+1; } } int main(){ int n, k, i, x, y; scanf("%d",&n); scanf("%d",&k); for(i=1; i<n; i++){ scanf("%d",&x); scanf("%d",&y); v[x].pb(y); v[y].pb(x); } B[1]=true; DFS(1); if(dp[1]>k) printf("NE\n"); else printf("DA\n"); return 0; }

Compilation message (stderr)

burza.cpp: In function 'int main()':
burza.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
burza.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  scanf("%d",&k);
      |  ~~~~~^~~~~~~~~
burza.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%d",&x);
      |   ~~~~~^~~~~~~~~
burza.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d",&y);
      |   ~~~~~^~~~~~~~~
#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...