Submission #415909

#TimeUsernameProblemLanguageResultExecution timeMemory
415909LouayFarahFriend (IOI14_friend)C++14
0 / 100
1056 ms42244 KiB
#include "bits/stdc++.h" #include "friend.h" using namespace std; vector<set<int>> adj; set<int> em; vector<bool> denied; int dfs(int u, int n, int c[]) { int r = c[u]; int temp = c[u]; denied[u] = true; for(auto v: adj[u]) denied[v] = true; for(int i = 0; i<n; i++) { if(!denied[i]) { int val = dfs(i, n, c); r = max(r, temp + val); } } return r; } int findSample(int n, int confidence[], int host[], int protocol[]) { adj.assign(n, em); for(int i = 1; i<n; i++) { if(protocol[i]==0) { int x = host[i]; adj[x].insert(i); adj[i].insert(x); } else if(protocol[i]==1) { int x = host[i]; for(auto v: adj[x]) { adj[v].insert(i); adj[i].insert(v); } } else { int x = host[i]; adj[x].insert(i); adj[i].insert(x); for(auto v: adj[x]) { adj[v].insert(i); adj[i].insert(v); } } } int res = 0; for(int i = 0; i<n; i++) { denied.assign(n, false); int maxi = dfs(i, n, confidence); res = max(res, maxi); } return res; }
#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...