제출 #780552

#제출 시각아이디문제언어결과실행 시간메모리
780552fatemetmhr친구 (IOI14_friend)C++17
35 / 100
8 ms12132 KiB
//  ~ Be Name Khoda ~  //

#include "friend.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")

using namespace std;

typedef long long ll;

#define pb       push_back
#define mp       make_pair
#define all(x)   x.begin(), x.end()
#define fi       first
#define se       second

const int maxn  =  1e6   + 10;
const int maxn5 =  5e5   + 10;
const int maxnt =  1.2e6 + 10;
const int maxn3 =  1e3   + 10;
const int mod   =  1e9   + 7;
const ll  inf   =  1e18;

int cmp[maxn5], hs[maxn5], ty[maxn5];
ll val[maxn5][2];
int n, dp[maxn5][2], mat[maxn5];
vector <int> adj[maxn5];
bool mark[maxn5];

// Find out best sample
int findSample(int n,int confidence[], int host[], int protocol[]){
	::n = n;
	for(int i = 1; i < n; i++){
		val[i][1] = confidence[i];
		hs[i] = host[i];
		ty[i] = protocol[i];
	}

	val[0][1] = confidence[0];

	for(int i = n - 1; i; i--){
		int v = hs[i];
		if(ty[i] == 0){
			val[v][0] += max(val[i][0], val[i][1]);
			val[v][1] += val[i][0];
		}
		if(ty[i] == 1){
			val[v][0] += val[i][0];
			val[v][1] += val[i][1];
		}
		if(ty[i] == 2){
			val[v][0] = max(val[v][0], val[i][0]);
			val[v][1] = max(val[v][1], val[i][1]);
		}
	}
	return max(val[0][0], val[0][1]);
}
#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...