This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include <iostream>
#include <vector>
#include <set>
using namespace std;
vector<set<int>> friends(1005);
int findSample(int n,int confidence[],int host[],int protocol[]){
int type[3] = {0,0,0};
for(int i = 1;i<n;i++)type[protocol[i]]++;
if(type[0] == 0 && type[2] == 0){
int ans = 0;
for(int i = 0;i<n;i++)ans += confidence[i];
return ans;
}
if(type[0] == 0 && type[1] == 0){
int ans = 0;
for(int i = 0;i<n;i++)ans = max(confidence[i],ans);
return ans;
}
if(n<=10){
for(int i = 1;i<n;i++){
if(protocol[i] == 0){
friends[host[i]].insert(i);
friends[i].insert(host[i]);
}else if(protocol[i] == 1){
for(int a:friends[host[i]]){
friends[i].insert(a);
friends[a].insert(i);
}
}else{
friends[host[i]].insert(i);
friends[i].insert(host[i]);
for(int a:friends[host[i]]){
friends[i].insert(a);
friends[a].insert(i);
}
}
}
for(int i = 0;i<n;i++)if(friends[i].count(i))friends[i].erase(i);
// for(int i = 0;i<n;i++){
// cerr << i << " -> ";
// for(int a:friends[i])cerr << a << " ";
// cerr << endl;
// }
int ans = 0;
for(int k=1;k<(1<<n);k++){
bool can = 0;
int temp = 0;
cerr << k << " -> ";
for(int j = 0;j<n;j++){
if(can)break;
cerr << ((1<<j)&k);
if((1<<j)&k)continue;
temp += confidence[j];
for(int l = 0;l<n;l++){
if(can)break;
if(j == l)continue;
if((1<<l)&k)continue;
if(friends[j].count(l) != 0){
can = 1;
// cerr << "{" << j << "," << l << "} ";
}
}
}
// cerr << " " << can << " " << temp << endl;
if(can == 0)ans = max(ans,temp);
}
return ans;
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |