Submission #1027654

# Submission time Handle Problem Language Result Execution time Memory
1027654 2024-07-19T08:26:19 Z dozer Friend (IOI14_friend) C++14
19 / 100
2 ms 6752 KB
#define __MAXSIZE__ 100002
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define mid (l + r) / 2
#define LL node * 2
#define RR node * 2 + 1
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define ll long long
#define MAXN 200005


const int modulo = 1e9+7;
const ll INF = 2e18 + 7;

int dp[2][MAXN], arr[MAXN];
vector<int> adj[MAXN];

void dfs(int node){
	dp[1][node] = dp[0][node] = 0;
	for (auto i : adj[node]){
		dfs(i);
		dp[1][node] += dp[0][i];
		dp[0][node] += dp[1][i];
	}
	dp[0][node] += arr[node];
	dp[0][node] = max(dp[0][node], dp[1][node]);
}


// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
	int ans=0;
	for (int i = 0; i < n; i++){
		adj[i].clear();
		arr[i] = confidence[i];
	}
	for (int i = 1; i < n; i++){
		if (protocol[i] == 0) {
			adj[host[i]].pb(i);
		}
		
	}

	dfs(0);
	return dp[0][0];
}

/*
// Confidence
int confidence[__MAXSIZE__];

// Host
int host[__MAXSIZE__];

// Protocol
int protocol[__MAXSIZE__];

// Main
int main(void)
{
	fileio();
	int n,i;

	// Number of people
	assert(scanf("%d",&n)==1);
	
	// Confidence
	for(i=0;i<n;i++)
		assert(scanf("%d",&confidence[i])==1);
	
	// Host and Protocol
	for(i=1;i<n;i++)
		assert(scanf("%d %d",&host[i],&protocol[i])==2);
	
	// Answer
	printf("%d\n",findSample(n,confidence,host,protocol));
	return 0;
}
*/

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:40:6: warning: unused variable 'ans' [-Wunused-variable]
   40 |  int ans=0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Incorrect 1 ms 6748 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 2 ms 6744 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 2 ms 6744 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6752 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Incorrect 1 ms 6748 KB Output isn't correct
8 Halted 0 ms 0 KB -