이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "friend.h"
#define MAXN 500007
using namespace std;
int n;
vector<int> v[MAXN];
long long ans,cost[MAXN];
bool li[MAXN];
void brute(int x,long long res){
if(x==-1){
ans=max(ans,res);
return;
}
brute(x-1,res);
int br=0;
for(int i:v[x]){
if(li[i])br++;
}
if(br==0){
li[x]=true;
brute(x-1,res+cost[x]);
li[x]=false;
}
}
int findSample(int N,int confidence[],int host[],int protocol[]){
//int findSample(int N,vector<int> confidence,vector<int> host,vector<int> protocol){
n=N;
for(int i=0;i<n;i++)cost[i]=confidence[i];
for(int i=1;i<=n-1;i++){
if(protocol[i]==0 or protocol[i]==2){
v[host[i]].push_back(i);
v[i].push_back(host[i]);
}
if(protocol[i]==1 or protocol[i]==2){
for(int f:v[host[i]]){
v[f].push_back(i);
v[i].push_back(f);
}
}
}
brute(n-1,0);
return ans;
}
/*int main(){
cout<<findSample(6,{13,3,6,20,10,15},{0,0,0,1,2,0},{0,0,1,2,1,0})<<"\n";
return 0;
}*/
# | 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... |