제출 #424378

#제출 시각아이디문제언어결과실행 시간메모리
424378dreezy친구 (IOI14_friend)C++17
100 / 100
36 ms2116 KiB
#include <bits/stdc++.h>
#include "friend.h"
using namespace std;


/*******************/
#define pi pair<int,int>
#define ll long long
#define f first
#define s second
#define pb push_back

int findSample(int n,int confidence[],int host[],int protocol[]){
	
	vector<int> yes(n, 0), no(n, 0);
	
	for(int i =0;i<n ;i++) yes[i] = confidence[i];
	
	
	for(int i=n-1; i>0; i--){
		if(protocol[i]== 0){//yo soy tu amigo
			yes[host[i]] += no[i];
			no[host[i]] += max(yes[i], no[i]);
		}
		else if(protocol[i] == 1){//mis amigos son tus amigos
			yes[host[i]] = max({yes[i] + no[host[i]],yes[host[i]] + no[i], yes[i] + yes[host[i]]});
			no[host[i]] += no[i];
		}
		else{//somos tus amigos
			yes[host[i]] = max(yes[i] + no[host[i]], no[i] + yes[host[i]]);
			no[host[i]] +=  no[i];
		}
	}
	
	return max(yes[0], no[0]);
}

/*******************/
#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...