Submission #430629

#TimeUsernameProblemLanguageResultExecution timeMemory
430629Rouge_HugoFriend (IOI14_friend)C++14
0 / 100
3 ms588 KiB
#include "friend.h" #include<bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; const int N=1009; vector<int>v[N]; int vis[N][2],a[N]; int dfs(int x,int p) { vis[x][1]=a[x]; for(auto it:v[x]) { if(it==p)continue; dfs(it,x); vis[x][0]+=vis[it][1]; vis[x][1]+=vis[it][0]; } vis[x][1]=max(vis[x][1],vis[x][0]); } int findSample(int n,int c[],int h[],int p[]){ for(int i=1;i<n;i++) { v[h[i]].pb(i); v[i].pb(h[i]); } for(int i=0;i<n;i++)a[i]=c[i]; dfs(0,0); vis[0][0]=max(vis[0][0],vis[0][1]); return vis[0][0]; } /* 5 1 100 1 1 100 0 0 0 0 1 1 2 2 */

Compilation message (stderr)

friend.cpp: In function 'int dfs(int, int)':
friend.cpp:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }
      | ^
#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...