Submission #344711

#TimeUsernameProblemLanguageResultExecution timeMemory
344711pit4hFriend (IOI14_friend)C++14
11 / 100
1082 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, vector<int>()); for(int i=1; i<n; ++i) { if(protocol[i]!=0) { for(int j: g[host[i]]) { g[i].push_back(j); g[j].push_back(i); } } if(protocol[i]!=1) { g[i].push_back(host[i]); g[host[i]].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(j!=i && 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...