Submission #841302

# Submission time Handle Problem Language Result Execution time Memory
841302 2023-09-01T13:06:44 Z serifefedartar Political Development (BOI17_politicaldevelopment) C++17
100 / 100
1154 ms 26040 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 20
#define MAXN 50005
 
vector<set<int>> graph;
int deg[MAXN], active[MAXN];
int main() {
	fast
	int N, K, x, D; 
	cin >> N >> K;
 
	graph = vector<set<int>>(N, set<int>());
	queue<int> q;
	for (int i = 0; i < N; i++)
		active[i] = true;
	for (int i = 0; i < N; i++) {
		cin >> deg[i];
		for (int j = 0; j < deg[i]; j++) {
			cin >> x;
			graph[i].insert(x);
		}

		if (deg[i] < K)
			q.push(i);
	}
 
	int ans = 1;
	while (!q.empty()) {
		int node = q.front();
		q.pop();
 	
		if (!active[node])
			continue;

		vector<int> adj;
		for (auto u : graph[node]) {
			if (active[u])
				adj.push_back(u);
		}
		int degree = adj.size();
		
		int mx_mask = (1<<degree) - 1;
		for (int msk = 1; msk <= mx_mask; msk++) {
			int k = __builtin_popcount(msk);
			if (k + 1 <= ans)
				continue;
			vector<int> taken;
			taken.push_back(node);
			bool check = true;
			for (int j = 0; j < degree; j++) {
				if ((1<<j) & msk) {
					for (auto u : taken) {
						if (graph[adj[j]].count(u) == 0)
							check = false;
					}
					taken.push_back(adj[j]);
				}
			}
 
			if (check)
				ans = max(ans, k + 1);
		}
 
		for (auto u : graph[node]) {
			deg[u]--;
			if (deg[u] < K)
				q.push(u);
		}
		active[node] = false;
	}
	cout << ans << "\n";
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:16:15: warning: unused variable 'D' [-Wunused-variable]
   16 |  int N, K, x, D;
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Correct 2 ms 980 KB Output is correct
6 Correct 2 ms 980 KB Output is correct
7 Correct 2 ms 1108 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Correct 2 ms 980 KB Output is correct
6 Correct 2 ms 980 KB Output is correct
7 Correct 2 ms 1108 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 1108 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 1108 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 852 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 3 ms 1108 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 2 ms 1108 KB Output is correct
28 Correct 3 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 3 ms 1236 KB Output is correct
31 Correct 3 ms 1236 KB Output is correct
32 Correct 3 ms 1236 KB Output is correct
33 Correct 4 ms 1236 KB Output is correct
34 Correct 3 ms 1236 KB Output is correct
35 Correct 2 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 4 ms 1492 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 4 ms 1492 KB Output is correct
43 Correct 4 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 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 Correct 1154 ms 25984 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 209 ms 25948 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1129 ms 26000 KB Output is correct
16 Correct 253 ms 25984 KB Output is correct
17 Correct 643 ms 25952 KB Output is correct
18 Correct 806 ms 26040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Correct 2 ms 980 KB Output is correct
6 Correct 2 ms 980 KB Output is correct
7 Correct 2 ms 1108 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 1108 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 1108 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 852 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 3 ms 1108 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 2 ms 1108 KB Output is correct
28 Correct 3 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 3 ms 1236 KB Output is correct
31 Correct 3 ms 1236 KB Output is correct
32 Correct 3 ms 1236 KB Output is correct
33 Correct 4 ms 1236 KB Output is correct
34 Correct 3 ms 1236 KB Output is correct
35 Correct 2 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 4 ms 1492 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 4 ms 1492 KB Output is correct
43 Correct 4 ms 1492 KB Output is correct
44 Correct 7 ms 2600 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 4 ms 1492 KB Output is correct
47 Correct 17 ms 2504 KB Output is correct
48 Correct 4 ms 1492 KB Output is correct
49 Correct 17 ms 2388 KB Output is correct
50 Correct 26 ms 2388 KB Output is correct
51 Correct 305 ms 4356 KB Output is correct
52 Correct 2 ms 1108 KB Output is correct
53 Correct 1079 ms 4968 KB Output is correct
54 Correct 674 ms 4824 KB Output is correct
55 Correct 2 ms 1108 KB Output is correct
56 Correct 2 ms 1104 KB Output is correct
57 Correct 1 ms 596 KB Output is correct
58 Correct 1064 ms 5400 KB Output is correct
59 Correct 4 ms 1672 KB Output is correct
60 Correct 3 ms 1108 KB Output is correct
61 Correct 4 ms 1748 KB Output is correct
62 Correct 4 ms 1620 KB Output is correct
63 Correct 8 ms 2772 KB Output is correct
64 Correct 6 ms 2536 KB Output is correct
65 Correct 4 ms 1492 KB Output is correct
66 Correct 4 ms 1620 KB Output is correct
67 Correct 18 ms 3156 KB Output is correct
68 Correct 7 ms 2516 KB Output is correct
69 Correct 4 ms 1492 KB Output is correct
70 Correct 9 ms 2516 KB Output is correct
71 Correct 12 ms 3044 KB Output is correct
72 Correct 15 ms 2968 KB Output is correct
73 Correct 2 ms 1108 KB Output is correct
74 Correct 8 ms 2516 KB Output is correct
75 Correct 11 ms 3020 KB Output is correct
76 Correct 11 ms 2036 KB Output is correct
77 Correct 196 ms 3660 KB Output is correct
78 Correct 2 ms 1108 KB Output is correct
79 Correct 98 ms 1940 KB Output is correct
80 Correct 11 ms 2040 KB Output is correct
81 Correct 201 ms 3588 KB Output is correct
82 Correct 1 ms 588 KB Output is correct
83 Correct 100 ms 1952 KB Output is correct
84 Correct 91 ms 3096 KB Output is correct
85 Correct 1 ms 596 KB Output is correct
86 Correct 21 ms 3092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Correct 2 ms 980 KB Output is correct
6 Correct 2 ms 980 KB Output is correct
7 Correct 2 ms 1108 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 1108 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 1108 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 852 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 3 ms 1108 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 2 ms 1108 KB Output is correct
28 Correct 3 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 3 ms 1236 KB Output is correct
31 Correct 3 ms 1236 KB Output is correct
32 Correct 3 ms 1236 KB Output is correct
33 Correct 4 ms 1236 KB Output is correct
34 Correct 3 ms 1236 KB Output is correct
35 Correct 2 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 4 ms 1492 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 4 ms 1492 KB Output is correct
43 Correct 4 ms 1492 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 88 ms 17128 KB Output is correct
46 Correct 32 ms 10428 KB Output is correct
47 Correct 108 ms 17296 KB Output is correct
48 Correct 101 ms 17204 KB Output is correct
49 Correct 25 ms 7892 KB Output is correct
50 Correct 234 ms 22568 KB Output is correct
51 Correct 137 ms 17292 KB Output is correct
52 Correct 28 ms 7968 KB Output is correct
53 Correct 25 ms 7916 KB Output is correct
54 Correct 4 ms 3156 KB Output is correct
55 Correct 232 ms 22564 KB Output is correct
56 Correct 10 ms 5588 KB Output is correct
57 Correct 20 ms 7896 KB Output is correct
58 Correct 25 ms 10676 KB Output is correct
59 Correct 10 ms 5588 KB Output is correct
60 Correct 10 ms 5588 KB Output is correct
61 Correct 27 ms 10644 KB Output is correct
62 Correct 19 ms 8108 KB Output is correct
63 Correct 50 ms 11464 KB Output is correct
64 Correct 10 ms 5588 KB Output is correct
65 Correct 55 ms 13908 KB Output is correct
66 Correct 18 ms 8148 KB Output is correct
67 Correct 38 ms 11512 KB Output is correct
68 Correct 51 ms 13340 KB Output is correct
69 Correct 50 ms 13920 KB Output is correct
70 Correct 22 ms 8164 KB Output is correct
71 Correct 57 ms 13368 KB Output is correct
72 Correct 37 ms 11148 KB Output is correct
73 Correct 98 ms 15616 KB Output is correct
74 Correct 22 ms 8088 KB Output is correct
75 Correct 27 ms 6452 KB Output is correct
76 Correct 46 ms 11088 KB Output is correct
77 Correct 100 ms 15504 KB Output is correct
78 Correct 45 ms 7892 KB Output is correct
79 Correct 25 ms 6404 KB Output is correct
80 Correct 13 ms 3412 KB Output is correct
81 Correct 45 ms 7968 KB Output is correct
82 Correct 58 ms 13240 KB Output is correct
83 Correct 15 ms 3448 KB Output is correct
84 Correct 55 ms 13172 KB Output is correct