Submission #811029

# Submission time Handle Problem Language Result Execution time Memory
811029 2023-08-06T21:03:40 Z tch1cherin Political Development (BOI17_politicaldevelopment) C++17
0 / 100
88 ms 53208 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<set<int>> graph(N);
	set<pair<int, int>> nodes;
	for (int node = 0; node < N; node++) {
		int degree;
		cin >> degree;
		nodes.emplace(degree, node);
		for (int j = 0; j < degree; j++) {
			int neighbour;
			cin >> neighbour;
			graph[node].insert(neighbour);
		}
	}
	vector<int> to(N, -1);
	int answer = 0;
	while (!nodes.empty()) {
		auto [degree, node] = *nodes.begin();
		nodes.erase({degree, node});
		assert(degree <= K);
		vector<int> neighbours;
		to[node] = 0;
		for (int i = 0; i < degree; i++) {
			int neighbour = *graph[node].begin();
			nodes.erase({(int)graph[neighbour].size(), neighbour});
			graph[node].erase(neighbour);
			graph[neighbour].erase(node);
			nodes.emplace((int)graph[neighbour].size(), neighbour);
			to[neighbour] = 1 + i;
			neighbours.push_back(neighbour);
		}
		vector<int16_t> small_graph(degree + 1);
		small_graph[to[node]] = (1 << (degree + 1)) - 1;
		for (int x : neighbours) {
			small_graph[to[x]] |= 1 << to[x];
			small_graph[to[x]] |= 1 << to[node];
			for (int y : graph[x]) {
				if (to[y] != -1) {
					small_graph[to[x]] |= 1 << to[y];
				}
			}
		}
		for (int clique = 0; clique < (1 << degree); clique++) {
			int16_t intersection = small_graph[node];
			for (int vertex = 1; vertex < degree + 1; vertex++) {
				if ((clique >> (vertex - 1)) & 1) {
					intersection &= small_graph[vertex];
				}
			}
			if (((clique << 1) | 1) == intersection) {
				answer = max(answer, __builtin_popcount(intersection));
			}
		}
		to[node] = -1;
		for (int neighbour : neighbours) {
			to[neighbour] = -1;
		}
	}
	cout << answer << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1236 KB Output is correct
4 Correct 85 ms 1236 KB Output is correct
5 Correct 85 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 1 ms 724 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1236 KB Output is correct
4 Correct 85 ms 1236 KB Output is correct
5 Correct 85 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 1 ms 724 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Runtime error 88 ms 53208 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1236 KB Output is correct
4 Correct 85 ms 1236 KB Output is correct
5 Correct 85 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 1 ms 724 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1236 KB Output is correct
4 Correct 85 ms 1236 KB Output is correct
5 Correct 85 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 1 ms 724 KB Output isn't correct
11 Halted 0 ms 0 KB -