Submission #1065302

#TimeUsernameProblemLanguageResultExecution timeMemory
1065302Mr_HusanboyFriend (IOI14_friend)C++17
19 / 100
1 ms600 KiB
#include "friend.h" #include<vector> #include <algorithm> using namespace std; // Find out best sample vector<vector<int>> g; vector<array<int,2>> dp; vector<int> val; void dfs(int i){ dp[i][0] = dp[i][1] = 0; for(auto u : g[i]){ dfs(u); dp[i][0] += max(dp[u][1], dp[u][0]); dp[i][1] += dp[u][0]; } dp[i][1] += val[i]; } int findSample(int n,int confidence[],int host[],int protocol[]){ g.resize(n); dp.resize(n); val.resize(n); for(int i = 0; i < n; i ++){ val[i] = confidence[i]; } for(int i = 1; i < n; i ++){ g[host[i]].push_back(i); } dfs(0); return max(dp[0][0], dp[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...