Submission #719138

# Submission time Handle Problem Language Result Execution time Memory
719138 2023-04-05T11:55:07 Z mseebacher Friend (IOI14_friend) C++17
19 / 100
6 ms 8404 KB
#include "friend.h"
#include <bits/stdc++.h> 

using namespace std;

#define MAX_N (int) 1e3+10

vector<int> friends[MAX_N];
vector<bool> vis(MAX_N,0);
vector<vector<long long>> dp(MAX_N,vector<long long>(MAX_N,0));

int *dummy;

void dfs(int x,int e){
	if(friends[x].size() == 1){
		dp[x][1] = dummy[x];
	}
	long long mit = 0;
	long long ohne = 0;
	for(auto s: friends[x]){
		if(s == e) continue;
		dfs(s,x);
		mit += dp[s][0];
		ohne += max(dp[s][0],dp[s][1]);
	}
	dp[x][1] = dummy[x]+mit;
	dp[x][0] = ohne;
}

// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
	dummy = confidence;
	for(int i = 1;i<n;i++){
		friends[i].push_back(host[i]);
		friends[host[i]].push_back(i);
	}	
	dfs(0,-1);
	return max(dp[0][1],dp[0][0]);
}

# Verdict Execution time Memory Grader output
1 Correct 6 ms 8276 KB Output is correct
2 Correct 4 ms 8276 KB Output is correct
3 Correct 4 ms 8276 KB Output is correct
4 Correct 5 ms 8304 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 4 ms 8276 KB Output is correct
7 Incorrect 4 ms 8276 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8272 KB Output is correct
2 Correct 5 ms 8276 KB Output is correct
3 Correct 5 ms 8276 KB Output is correct
4 Correct 5 ms 8276 KB Output is correct
5 Correct 5 ms 8404 KB Output is correct
6 Correct 4 ms 8404 KB Output is correct
7 Correct 6 ms 8280 KB Output is correct
8 Correct 5 ms 8404 KB Output is correct
9 Correct 4 ms 8356 KB Output is correct
10 Correct 6 ms 8276 KB Output is correct
11 Correct 4 ms 8364 KB Output is correct
12 Correct 4 ms 8380 KB Output is correct
13 Correct 5 ms 8404 KB Output is correct
14 Correct 5 ms 8276 KB Output is correct
15 Correct 5 ms 8404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8276 KB Output is correct
2 Correct 4 ms 8276 KB Output is correct
3 Incorrect 4 ms 8276 KB Output isn't correct
4 Halted 0 ms 0 KB -