Submission #1115705

#TimeUsernameProblemLanguageResultExecution timeMemory
1115705lgmultiBurza (COCI16_burza)C++14
0 / 160
2 ms1616 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const ll MAXN=405; ll n,k; ll g[MAXN][MAXN]; vector<ll> son[MAXN]; ll father[MAXN]; void dfs(ll x){ ll i,j; for(i=1;i<=n;i++){ if(g[x][i] && father[x]!=i){ father[i]=x; son[x].push_back(i); dfs(i); } } } ll maxtravtime=0; void dfs2(ll x){ ll i,j; maxtravtime++; ll sonWithTheMostGrandson=0,sonWithTheSecondMostGrandson=0; for(i=0;i<son[x].size();i++){ if(son[son[x][i]].size()>=son[sonWithTheMostGrandson].size()){ sonWithTheSecondMostGrandson=sonWithTheMostGrandson; sonWithTheMostGrandson=son[x][i]; } else if(son[son[x][i]].size()>=son[sonWithTheSecondMostGrandson].size()) sonWithTheSecondMostGrandson=son[x][i]; } //cout<<x<<": "<<sonWithTheMostGrandson<<' '<<sonWithTheSecondMostGrandson<<endl; if(sonWithTheSecondMostGrandson==0) return; dfs2(sonWithTheSecondMostGrandson); } int main(){ ll i,j; cin>>n>>k; for(i=1;i<n;i++){ ll u,v; cin>>u>>v; g[u][v]=g[v][u]=1; } dfs(1); dfs2(1); cout<<(maxtravtime<=k ? "DA" : "NE")<<endl; return 0; }

Compilation message (stderr)

burza.cpp: In function 'void dfs(long long int)':
burza.cpp:14:10: warning: unused variable 'j' [-Wunused-variable]
   14 |     ll i,j;
      |          ^
burza.cpp: In function 'void dfs2(long long int)':
burza.cpp:30:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(i=0;i<son[x].size();i++){
      |             ~^~~~~~~~~~~~~~
burza.cpp:27:10: warning: unused variable 'j' [-Wunused-variable]
   27 |     ll i,j;
      |          ^
burza.cpp: In function 'int main()':
burza.cpp:47:10: warning: unused variable 'j' [-Wunused-variable]
   47 |     ll i,j;
      |          ^
#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...