Submission #114382

# Submission time Handle Problem Language Result Execution time Memory
114382 2019-06-01T07:03:50 Z E869120 Friend (IOI14_friend) C++14
35 / 100
11 ms 2816 KB
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> G[100009];
int dp[100009][2], A[100009];

void dfs(int pos) {
	int m1 = 0, m2 = 0;
	for (int i = 0; i < G[pos].size(); i++) {
		dfs(G[pos][i]);
		m1 += max(dp[G[pos][i]][0], dp[G[pos][i]][1]);
		m2 += dp[G[pos][i]][1];
	}
	m2 += A[pos];
	dp[pos][0] = m2; dp[pos][1] = m1;
}

// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
	int bit = 0;
	for (int i = 1; i <= n - 1; i++) bit |= (1 << protocol[i]);
	
	if (bit == 1) {
		// Subtask 4.
		for (int i = 0; i < n; i++) A[i] = confidence[i];
		for (int i = 1; i <= n - 1; i++) G[host[i]].push_back(i);
		dfs(0);
		return max(dp[0][0], dp[0][1]);
	}
	if (bit == 2) {
		// Subtask 2.
		int sum = 0; for (int i = 0; i < n; i++) sum += confidence[i];
		return sum;
	}
	if (bit == 4) {
		// Subtask 3.
		int sum = 0; for (int i = 0; i < n; i++) sum = max(sum, confidence[i]);
		return sum;
	}
	if (n <= 10) {
		// Subtask 5.
		
	}
	return -1;
}

Compilation message

friend.cpp: In function 'void dfs(int)':
friend.cpp:10:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < G[pos].size(); i++) {
                  ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Incorrect 4 ms 2688 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 4 ms 2660 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 4 ms 2688 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 5 ms 2688 KB Output is correct
5 Correct 4 ms 2816 KB Output is correct
6 Correct 5 ms 2816 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
9 Correct 4 ms 2688 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 4 ms 2688 KB Output is correct
12 Correct 5 ms 2816 KB Output is correct
13 Correct 5 ms 2816 KB Output is correct
14 Correct 5 ms 2688 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 11 ms 2688 KB Output is correct
5 Incorrect 5 ms 2688 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2816 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Incorrect 5 ms 2688 KB Output isn't correct
4 Halted 0 ms 0 KB -