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<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
int N,niz[maxn];
ll res=0;
vector<int> graf[maxn];
void grana(int a,int b){
graf[a].push_back(b);
graf[b].push_back(a);
}
bool uzeo[15];
void provera(){
for(int i=1;i<=N;i++){
if(!uzeo[i])
continue;
for(int x:graf[i])
if(uzeo[x])
return;
}
ll skor=0;
for(int i=1;i<=N;i++)
if(uzeo[i])
skor+=niz[i];
res=max(res,skor);
}
void rek(int gde){
if(gde==N+1){
provera();
return;
}
uzeo[gde]=false;
rek(gde+1);
uzeo[gde]=true;
rek(gde+1);
return;
}
int findSample(int n,int confidence[],int host[],int protocol[]){
N=n;
for(int i=1;i<=N;i++)
niz[i]=confidence[i-1];
for(int i=1;i<N;i++){
int x=host[i]+1;
int p=protocol[i];
if(p==1 or p==2){
for(int aa:graf[x])
grana(aa,i+1);
}
if(p==0 or p==2)
grana(x,i+1);
}
rek(1);
return res;
}
# | 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... |