Submission #260448

# Submission time Handle Problem Language Result Execution time Memory
260448 2020-08-10T09:24:48 Z dolphingarlic Political Development (BOI17_politicaldevelopment) C++14
100 / 100
1864 ms 24568 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

set<int> graph[50000];
bool tried[50000];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	queue<int> q;
	for (int i = 0; i < n; i++) {
		int s;
		cin >> s;
		if (s < k) {
			tried[i] = true;
			q.push(i);
		}
		while (s--) {
			int b;
			cin >> b;
			graph[i].insert(b);
		}
	}

	int ans = 0;
	while (q.size()) {
		int curr = q.front();
		q.pop();

		for (int i = 0; i < (1 << graph[curr].size()); i++) {
			if (__builtin_popcount(i) <= ans) continue;
			vector<int> adj;
			int tmp = i;
			for (int j : graph[curr]) {
				if (tmp & 1) adj.push_back(j);
				tmp >>= 1;
			}
			bool good = true;
			for (int j = 0; j < adj.size(); j++) {
				for (int l = j + 1; l < adj.size(); l++) {
					good &= graph[adj[j]].find(adj[l]) != graph[adj[j]].end();
				}
			}
			if (good) ans = __builtin_popcount(i);
		}

		for (int i : graph[curr]) {
			graph[i].erase(curr);
			if (!tried[i] && graph[i].size() < k) {
				tried[i] = true;
				q.push(i);
			}
		}
		graph[curr].clear();
	}

	cout << ans + 1;
	return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:42:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < adj.size(); j++) {
                    ~~^~~~~~~~~~~~
politicaldevelopment.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int l = j + 1; l < adj.size(); l++) {
                         ~~^~~~~~~~~~~~
politicaldevelopment.cpp:52:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (!tried[i] && graph[i].size() < k) {
                     ~~~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 5 ms 3328 KB Output is correct
4 Correct 5 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 5 ms 3328 KB Output is correct
4 Correct 5 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 3264 KB Output is correct
12 Correct 5 ms 3200 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 6 ms 3200 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 4 ms 2944 KB Output is correct
21 Correct 3 ms 2944 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 6 ms 3328 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 7 ms 3328 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3200 KB Output is correct
28 Correct 6 ms 3328 KB Output is correct
29 Correct 5 ms 3200 KB Output is correct
30 Correct 8 ms 3456 KB Output is correct
31 Correct 8 ms 3328 KB Output is correct
32 Correct 6 ms 3456 KB Output is correct
33 Correct 8 ms 3328 KB Output is correct
34 Correct 6 ms 3328 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 4 ms 3072 KB Output is correct
38 Correct 4 ms 2944 KB Output is correct
39 Correct 4 ms 2880 KB Output is correct
40 Correct 8 ms 3712 KB Output is correct
41 Correct 5 ms 2880 KB Output is correct
42 Correct 8 ms 3712 KB Output is correct
43 Correct 8 ms 3712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2816 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 1842 ms 24440 KB Output is correct
12 Correct 2 ms 2688 KB Output is correct
13 Correct 405 ms 24312 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 1864 ms 24380 KB Output is correct
16 Correct 448 ms 24440 KB Output is correct
17 Correct 1111 ms 24568 KB Output is correct
18 Correct 1358 ms 24440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 5 ms 3328 KB Output is correct
4 Correct 5 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 3264 KB Output is correct
12 Correct 5 ms 3200 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 6 ms 3200 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 4 ms 2944 KB Output is correct
21 Correct 3 ms 2944 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 6 ms 3328 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 7 ms 3328 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3200 KB Output is correct
28 Correct 6 ms 3328 KB Output is correct
29 Correct 5 ms 3200 KB Output is correct
30 Correct 8 ms 3456 KB Output is correct
31 Correct 8 ms 3328 KB Output is correct
32 Correct 6 ms 3456 KB Output is correct
33 Correct 8 ms 3328 KB Output is correct
34 Correct 6 ms 3328 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 4 ms 3072 KB Output is correct
38 Correct 4 ms 2944 KB Output is correct
39 Correct 4 ms 2880 KB Output is correct
40 Correct 8 ms 3712 KB Output is correct
41 Correct 5 ms 2880 KB Output is correct
42 Correct 8 ms 3712 KB Output is correct
43 Correct 8 ms 3712 KB Output is correct
44 Correct 15 ms 4736 KB Output is correct
45 Correct 2 ms 2688 KB Output is correct
46 Correct 8 ms 3712 KB Output is correct
47 Correct 26 ms 4824 KB Output is correct
48 Correct 8 ms 3712 KB Output is correct
49 Correct 27 ms 4736 KB Output is correct
50 Correct 44 ms 4736 KB Output is correct
51 Correct 507 ms 6756 KB Output is correct
52 Correct 5 ms 3200 KB Output is correct
53 Correct 1437 ms 7240 KB Output is correct
54 Correct 1100 ms 7220 KB Output is correct
55 Correct 5 ms 3200 KB Output is correct
56 Correct 5 ms 3200 KB Output is correct
57 Correct 2 ms 2688 KB Output is correct
58 Correct 1280 ms 7288 KB Output is correct
59 Correct 7 ms 3712 KB Output is correct
60 Correct 5 ms 3200 KB Output is correct
61 Correct 7 ms 3712 KB Output is correct
62 Correct 8 ms 3712 KB Output is correct
63 Correct 14 ms 4736 KB Output is correct
64 Correct 13 ms 4608 KB Output is correct
65 Correct 7 ms 3584 KB Output is correct
66 Correct 7 ms 3712 KB Output is correct
67 Correct 32 ms 5248 KB Output is correct
68 Correct 12 ms 4480 KB Output is correct
69 Correct 7 ms 3584 KB Output is correct
70 Correct 15 ms 4608 KB Output is correct
71 Correct 23 ms 5120 KB Output is correct
72 Correct 20 ms 5120 KB Output is correct
73 Correct 5 ms 3200 KB Output is correct
74 Correct 16 ms 4608 KB Output is correct
75 Correct 19 ms 5120 KB Output is correct
76 Correct 19 ms 4096 KB Output is correct
77 Correct 306 ms 5632 KB Output is correct
78 Correct 5 ms 3200 KB Output is correct
79 Correct 158 ms 4224 KB Output is correct
80 Correct 19 ms 4096 KB Output is correct
81 Correct 311 ms 5632 KB Output is correct
82 Correct 3 ms 2944 KB Output is correct
83 Correct 161 ms 4344 KB Output is correct
84 Correct 157 ms 4992 KB Output is correct
85 Correct 4 ms 2944 KB Output is correct
86 Correct 38 ms 4992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 5 ms 3328 KB Output is correct
4 Correct 5 ms 3200 KB Output is correct
5 Correct 5 ms 3200 KB Output is correct
6 Correct 5 ms 3200 KB Output is correct
7 Correct 6 ms 3200 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 3264 KB Output is correct
12 Correct 5 ms 3200 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 6 ms 3200 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 4 ms 2944 KB Output is correct
21 Correct 3 ms 2944 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 6 ms 3328 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 7 ms 3328 KB Output is correct
26 Correct 6 ms 3328 KB Output is correct
27 Correct 5 ms 3200 KB Output is correct
28 Correct 6 ms 3328 KB Output is correct
29 Correct 5 ms 3200 KB Output is correct
30 Correct 8 ms 3456 KB Output is correct
31 Correct 8 ms 3328 KB Output is correct
32 Correct 6 ms 3456 KB Output is correct
33 Correct 8 ms 3328 KB Output is correct
34 Correct 6 ms 3328 KB Output is correct
35 Correct 4 ms 3072 KB Output is correct
36 Correct 4 ms 3072 KB Output is correct
37 Correct 4 ms 3072 KB Output is correct
38 Correct 4 ms 2944 KB Output is correct
39 Correct 4 ms 2880 KB Output is correct
40 Correct 8 ms 3712 KB Output is correct
41 Correct 5 ms 2880 KB Output is correct
42 Correct 8 ms 3712 KB Output is correct
43 Correct 8 ms 3712 KB Output is correct
44 Correct 2 ms 2688 KB Output is correct
45 Correct 165 ms 17144 KB Output is correct
46 Correct 66 ms 10232 KB Output is correct
47 Correct 157 ms 17144 KB Output is correct
48 Correct 161 ms 17144 KB Output is correct
49 Correct 44 ms 7928 KB Output is correct
50 Correct 292 ms 21912 KB Output is correct
51 Correct 160 ms 17144 KB Output is correct
52 Correct 40 ms 7928 KB Output is correct
53 Correct 41 ms 7840 KB Output is correct
54 Correct 6 ms 3072 KB Output is correct
55 Correct 293 ms 22136 KB Output is correct
56 Correct 25 ms 5496 KB Output is correct
57 Correct 38 ms 7928 KB Output is correct
58 Correct 58 ms 10360 KB Output is correct
59 Correct 19 ms 5664 KB Output is correct
60 Correct 24 ms 5504 KB Output is correct
61 Correct 60 ms 10232 KB Output is correct
62 Correct 37 ms 7928 KB Output is correct
63 Correct 82 ms 11384 KB Output is correct
64 Correct 19 ms 5504 KB Output is correct
65 Correct 126 ms 13740 KB Output is correct
66 Correct 37 ms 7928 KB Output is correct
67 Correct 69 ms 11376 KB Output is correct
68 Correct 93 ms 13048 KB Output is correct
69 Correct 110 ms 13688 KB Output is correct
70 Correct 37 ms 7892 KB Output is correct
71 Correct 101 ms 13048 KB Output is correct
72 Correct 74 ms 11044 KB Output is correct
73 Correct 172 ms 15096 KB Output is correct
74 Correct 38 ms 7928 KB Output is correct
75 Correct 48 ms 7552 KB Output is correct
76 Correct 72 ms 11000 KB Output is correct
77 Correct 173 ms 15360 KB Output is correct
78 Correct 78 ms 9088 KB Output is correct
79 Correct 45 ms 7552 KB Output is correct
80 Correct 19 ms 5248 KB Output is correct
81 Correct 77 ms 9088 KB Output is correct
82 Correct 88 ms 12668 KB Output is correct
83 Correct 19 ms 5248 KB Output is correct
84 Correct 89 ms 12536 KB Output is correct