Submission #111947

# Submission time Handle Problem Language Result Execution time Memory
111947 2019-05-16T22:34:07 Z luciocf Friend (IOI14_friend) C++14
27 / 100
32 ms 2680 KB
#include <bits/stdc++.h>
#include "friend.h"

using namespace std;

bool mark[12][12];

int findSample(int n, int confidence[], int host[], int protocol[])
{
	if (n > 10)
	{
		if (protocol[1] == 2)
		{
			int mx = 0;
			for (int i = 0; i < n; i++)
				mx = max(mx, confidence[i]);
			return mx;
		}

		int s = 0;
		for (int i = 0; i < n; i++)
			s += confidence[i];

		return s;
	}

	for (int i = 1; i < n; i++)
	{
		int h = host[i];

		if (protocol[i] == 0)
		{
			mark[i][h] = mark[h][i] = 1;
		}
		else if (protocol[i] == 1)
		{
			for (int j = 0; j < n; j++)
				if (mark[h][j])
					mark[i][j] = mark[j][i] = 1;
		}
		else
		{
			for (int j = 0; j < n; j++)
				if (mark[h][j])
					mark[i][j] = mark[j][i] = 1;
			mark[i][h] = mark[h][i] = 1;
		}
	}

	int ans = 0;

	for (int mask = 0; mask < (1<<n); mask++)
	{
		bool ok = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (mark[i][j] && mask&(1<<i) && mask&(1<<j))
					ok = 0;

		if (ok)
		{
			int aux = 0;
			for (int i = 0; i < n; i++)
				if (mask&(1<<i))
					aux += confidence[i];
			ans = max(ans, aux);
		}
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 3 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Incorrect 4 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Incorrect 32 ms 2680 KB Output isn't correct
13 Halted 0 ms 0 KB -