Submission #99283

# Submission time Handle Problem Language Result Execution time Memory
99283 2019-03-02T06:31:36 Z dndhk Friend (IOI14_friend) C++14
16 / 100
7 ms 2816 KB
#include "friend.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

const int MAX_N = 100000;
vector<pii> gp[MAX_N+1];
int N;
int c[MAX_N+1];
pii p[MAX_N+1];
int dp[MAX_N+1][2];

void dfs(int x){
	dp[x][1] = c[x];
	for(int j = gp[x].size()-1; j>=0; j--){
		pii i = gp[x][j];
		dfs(i.first);
		if(i.second==2){
			dp[x][1] = max(dp[x][1], dp[x][0] + dp[i.first][1]);
		}else if(i.second==1){
			dp[x][1] += dp[i.first][1];
			dp[x][1] = max(dp[x][1], dp[x][0] + dp[i.first][1]);
		}else{
			dp[x][0] += dp[i.first][1];
		}
	}
}


int findSample(int n, int confidence[], int host[], int protocol[]){
	N = n;
	for(int i=0; i<N; i++){
		c[i] = confidence[i];
		if(i!=0)	{
			p[i] = {host[i], protocol[i]};
			gp[host[i]].push_back({i, protocol[i]});
		}
	}
	dfs(0);
	return max(dp[0][0], dp[0][1]);
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2816 KB Output is correct
2 Incorrect 5 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 5 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 5 ms 2688 KB Output is correct
7 Correct 5 ms 2688 KB Output is correct
8 Correct 5 ms 2688 KB Output is correct
9 Correct 5 ms 2816 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 3 ms 2672 KB Output is correct
5 Correct 5 ms 2688 KB Output is correct
6 Correct 5 ms 2688 KB Output is correct
7 Correct 5 ms 2688 KB Output is correct
8 Correct 5 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2816 KB Output is correct
2 Incorrect 5 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2784 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Incorrect 5 ms 2748 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2816 KB Output is correct
2 Incorrect 4 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -