Submission #136147

#TimeUsernameProblemLanguageResultExecution timeMemory
136147arthurconmyFriend (IOI14_friend)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #ifndef ARTHUR_LOCAL #include "friend.h" #endif using namespace std; const int MAXN=1000; int C[MAXN]; int H[MAXN]; int P[MAXN]; vector<int> adj[MAXN]; int ans[2][MAXN]; bool vis[MAXN]; void dfs(int v) { vis[v]=1; for(auto u:adj[v]) { if(vis[u]) continue; dfs(u); ans[0][v] += ans[1][v]; ans[1][v] += ans[0][v]; } ans[1][v] = max(C[v]+ans[0][v],ans[1][v]); } int findSample(int n, int C_raw[], int H_raw[], int P_raw[]) { for(int i=0; i<n; i++) { C[i]=C_raw[i]; H[i]=H_raw[i]; P[i]=P_raw[i]; } for(int i=1; i<n; i++) { adj[i].push_back(H[i]); adj[H[i]].push_back(i); } dfs(0); return max(ans[0][0], ans[0][1]); }
#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...