Submission #115768

# Submission time Handle Problem Language Result Execution time Memory
115768 2019-06-09T04:59:23 Z thecodingwizard Friend (IOI14_friend) C++11
19 / 100
31 ms 1528 KB
#include <bits/stdc++.h>
#include "friend.h"

using namespace std;

#define FOR(a, b, c) for (int a = b; a < c; a++)
#define ll long long
#define vi vector<int>
#define pb push_back
#define mp make_pair

// Find out best sample
int findSample(int n, int confidence[], int host[], int protocol[]) {
	if (n <= 10) {
		// Subtask 1
		set<int> friends[n];
		FOR(i, 1, n) {
			int h = host[i], p = protocol[i];
			if (p == 0) {
				// IAmYourFriend
				friends[i].insert(h);
				friends[h].insert(i);
			} else if (p == 1) {
				// MyFriendsAreYourFriends
				for (int u : friends[h]) {
					friends[u].insert(i);
					friends[i].insert(u);
				}
			} else {
				// WeAreYourFriends
				friends[i].insert(h);
				friends[h].insert(i);
				for (int u : friends[h]) {
					friends[u].insert(i);
					friends[i].insert(u);
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < (1 << n); i++) {
			int curAns = 0;
			bool invalid = false;
			for (int j = 0; j < n; j++) {
				if (!(i & (1 << j))) continue;
				for (int f : friends[j]) {
					if (f == j) continue;
					if (i & (1 << f)) {
						invalid = true;
						break;
					}
				}
				if (invalid) break;
				curAns += confidence[j];
			}
			if (!invalid) ans = max(ans, curAns);
		}
		return ans;
	} else {
		// Subtask two: Sum all confidence values
		int ans = 0;
		for (int i = 0; i < n; i++) ans += confidence[i];
		return ans;
	}
	exit(1);
}
# Verdict Execution time Memory Grader output
1 Correct 3 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 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 3 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 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 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 2 ms 256 KB Output is correct
17 Correct 2 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 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 256 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 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 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 8 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 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 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Incorrect 31 ms 1528 KB Output isn't correct
13 Halted 0 ms 0 KB -