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 <bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
//#include "friend.h"
using namespace std;
const int N = 11;
int adj[N][N] ;
int findSample(int n , int* v, int* p , int* protocol ){
vector<int> add[n] ;
for(int i=1;i<n;i++){
if(protocol[i]==0||protocol[i]==2){
add[p[i]].push_back(i) ;
add[i].push_back(p[i]) ;
}
if(protocol[i]>0){
for(int x : add[p[i]]){
add[x].push_back(i);
add[i].push_back(x);
}
}
}
for(int i=0;i<n;i++) for(int x: add[i]) adj[i][x]=adj[x][i]=1;
int ans = 0 ;
for(int i=0;i<(1<<n);i++){
bool flg = 0 ;
for(int j=0;j<n;j++){
if((1<<j)&i){
for(int k=0;k<n;k++){
if(k==j) continue ;
if((1<<k)&i){
if(add[k][j]) flg = 1 ;
}
}
}
}
if(flg) continue ;
int res = 0 ;
for(int j=0;j<n;j++) if((1<<j)&i) res+=v[j] ;
ans=max(ans,res) ;
}
return ans ;
}
# | 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... |