Submission #415906

#TimeUsernameProblemLanguageResultExecution timeMemory
415906LouayFarahFriend (IOI14_friend)C++14
0 / 100
1098 ms42416 KiB
#include "bits/stdc++.h" #include "friend.h" using namespace std; vector<set<int>> adj; set<int> em; set<int> denied; vector<int> c; int dfs(int u, int n) { int r = c[u]; int temp = c[u]; denied.insert(u); for(auto v: adj[u]) denied.insert(v); for(int i = 0; i<n; i++) { if(!denied.count(i)) { int val = dfs(i, n); r = max(r, temp + val); } } return r; } int findSample(int n, int confidence[], int host[], int protocol[]) { c.resize(n); for(int i = 0; i<n; i++) c[i] = confidence[i]; 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.clear(); int maxi = dfs(i, n); 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...