Submission #344709

#TimeUsernameProblemLanguageResultExecution timeMemory
344709pit4hFriend (IOI14_friend)C++14
0 / 100
1093 ms65540 KiB
#include<bits/stdc++.h> #include "friend.h" using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]){ int ans = 0; vector<vector<int>> g(n); for(int i=1; i<n; ++i) { if(protocol[i]!=1) { g[i].push_back(host[i]); g[host[i]].push_back(i); } if(protocol[i]!=0) { for(int j: g[host[i]]) { g[i].push_back(j); g[j].push_back(i); } } } for(int mask=0; mask<(1<<n); ++mask) { vector<bool> on(n); int sum = 0; for(int i=0; i<n; ++i) { if(mask&(1<<i)) { on[i] = 1; sum += confidence[i]; } } for(int i=0; i<n; ++i) { if(on[i]) { for(int j: g[i]) { if(on[j]) sum = -1; } } } ans = max(ans, sum); } 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...