Submission #719138

#TimeUsernameProblemLanguageResultExecution timeMemory
719138mseebacherFriend (IOI14_friend)C++17
19 / 100
6 ms8404 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define MAX_N (int) 1e3+10 vector<int> friends[MAX_N]; vector<bool> vis(MAX_N,0); vector<vector<long long>> dp(MAX_N,vector<long long>(MAX_N,0)); int *dummy; void dfs(int x,int e){ if(friends[x].size() == 1){ dp[x][1] = dummy[x]; } long long mit = 0; long long ohne = 0; for(auto s: friends[x]){ if(s == e) continue; dfs(s,x); mit += dp[s][0]; ohne += max(dp[s][0],dp[s][1]); } dp[x][1] = dummy[x]+mit; dp[x][0] = ohne; } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ dummy = confidence; for(int i = 1;i<n;i++){ friends[i].push_back(host[i]); friends[host[i]].push_back(i); } dfs(0,-1); return max(dp[0][1],dp[0][0]); }
#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...