제출 #430632

#제출 시각아이디문제언어결과실행 시간메모리
430632Rouge_Hugo친구 (IOI14_friend)C++14
0 / 100
1 ms332 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]; 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=0;i<n-1;i++) { v[h[i]].pb(i-1); v[i-1].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 */
#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...