Submission #430635

#TimeUsernameProblemLanguageResultExecution timeMemory
430635Rouge_HugoFriend (IOI14_friend)C++14
19 / 100
1 ms460 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]; void dfs(int x,int p) { vis[x][1]=a[x];//cout<<x<<endl; 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]); //cout<<i<<" "<<h[i]<<endl; } 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 */
#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...