Submission #719094

#TimeUsernameProblemLanguageResultExecution timeMemory
719094mseebacherFriend (IOI14_friend)C++17
8 / 100
13 ms4440 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); int mx = 0; int *dummy; void dfs(int x,int e){ if(vis[x]) return; vis[x] = 1; mx = max(mx,dummy[x]); for(auto s: friends[x]){ dfs(s,x); } } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ dummy = confidence; long long ans = 0; for(int i = 1;i<n;i++){ for(int j = 0;j<(int)friends[host[i]].size();j++){ int f = friends[host[i]][j]; friends[f].push_back(i); friends[i].push_back(f); } friends[i].push_back(host[i]); friends[host[i]].push_back(i); } for(int i = 0;i<n;i++){ if(!vis[i]){ dfs(i,-1); ans += mx; mx = 0; } } return ans; }
#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...