제출 #136931

#제출 시각아이디문제언어결과실행 시간메모리
136931TuGSGeReL친구 (IOI14_friend)C++17
100 / 100
38 ms3448 KiB
#include "friend.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;

int dp[2][100001];

int findSample(int n,int confidence[],int host[],int protocol[])
{
	for (int i = 0; i < n; i++)
		dp[1][i] = confidence[i];
	
	for (int i = n - 1; i > 0; i--)
	{
		if ( protocol[i] == 0 )
		{
			dp[1][host[i]] = dp[1][host[i]] + dp[0][i];
			dp[0][host[i]] = max(dp[0][i] + dp[0][host[i]], dp[1][i] + dp[0][host[i]]);
		} else if ( protocol[i] == 1 ) {
			dp[1][host[i]] = max(max(dp[1][host[i]] + dp[0][i], dp[1][host[i]] + dp[1][i]), dp[0][host[i]] + dp[1][i]);
			dp[0][host[i]] = dp[0][host[i]] + dp[0][i];
		} else {
			dp[1][host[i]] = max(dp[1][host[i]] + dp[0][i], dp[1][i] + dp[0][host[i]]);
			dp[0][host[i]] = dp[0][host[i]] + dp[0][i];
		}
	}
	
	return max(dp[0][0], dp[1][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...