Submission #841285

# Submission time Handle Problem Language Result Execution time Memory
841285 2023-09-01T12:50:49 Z serifefedartar Political Development (BOI17_politicaldevelopment) C++17
62 / 100
3000 ms 25724 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 200005
 
vector<set<int>> graph;
vector<pair<int,int>> degree;
int main() {
	fast
	int N, K, x, D; 
	cin >> N >> K;
 
	graph = vector<set<int>>(N, set<int>());
	degree = vector<pair<int,int>>(N);
	for (int i = 0; i < N; i++)
		degree[i] = {0, i};
	for (int i = 0; i < N; i++) {
		cin >> D;
		for (int j = 0; j < D; j++) {
			cin >> x;
			graph[x].insert(i);
			graph[i].insert(x);
			degree[i].f++;
			degree[x].f++;
		}
	}
	sort(degree.begin(), degree.end());
 
	int ans = 1;
	for (auto u : degree) {
		int node = u.s;
		int degree = graph[node].size();
 
		vector<int> adj;
		for (auto u : graph[node])
			adj.push_back(u);
		
		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])
			graph[u].erase(node);
	}
	cout << ans << "\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 3 ms 980 KB Output is correct
4 Correct 3 ms 1012 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 3 ms 980 KB Output is correct
7 Correct 3 ms 980 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 0 ms 212 KB Output is correct
3 Correct 3 ms 980 KB Output is correct
4 Correct 3 ms 1012 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 3 ms 980 KB Output is correct
7 Correct 3 ms 980 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 3 ms 980 KB Output is correct
12 Correct 3 ms 980 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 1004 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 5 ms 980 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 3 ms 724 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 980 KB Output is correct
28 Correct 5 ms 1108 KB Output is correct
29 Correct 2 ms 980 KB Output is correct
30 Correct 4 ms 1108 KB Output is correct
31 Correct 4 ms 1108 KB Output is correct
32 Correct 4 ms 1108 KB Output is correct
33 Correct 4 ms 1108 KB Output is correct
34 Correct 4 ms 1108 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 2 ms 596 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 6 ms 1492 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 5 ms 1492 KB Output is correct
43 Correct 6 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 0 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1231 ms 24188 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 349 ms 25724 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1238 ms 25724 KB Output is correct
16 Correct 376 ms 25716 KB Output is correct
17 Correct 776 ms 25724 KB Output is correct
18 Correct 924 ms 25720 KB Output is correct
# 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 3 ms 980 KB Output is correct
4 Correct 3 ms 1012 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 3 ms 980 KB Output is correct
7 Correct 3 ms 980 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 3 ms 980 KB Output is correct
12 Correct 3 ms 980 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 1004 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 5 ms 980 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 3 ms 724 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 980 KB Output is correct
28 Correct 5 ms 1108 KB Output is correct
29 Correct 2 ms 980 KB Output is correct
30 Correct 4 ms 1108 KB Output is correct
31 Correct 4 ms 1108 KB Output is correct
32 Correct 4 ms 1108 KB Output is correct
33 Correct 4 ms 1108 KB Output is correct
34 Correct 4 ms 1108 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 2 ms 596 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 6 ms 1492 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 5 ms 1492 KB Output is correct
43 Correct 6 ms 1492 KB Output is correct
44 Correct 9 ms 2388 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 6 ms 1492 KB Output is correct
47 Correct 31 ms 2388 KB Output is correct
48 Correct 6 ms 1620 KB Output is correct
49 Correct 32 ms 2644 KB Output is correct
50 Correct 41 ms 2644 KB Output is correct
51 Correct 2630 ms 4728 KB Output is correct
52 Correct 3 ms 1108 KB Output is correct
53 Correct 746 ms 5216 KB Output is correct
54 Execution timed out 3049 ms 5252 KB Time limit exceeded
55 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 3 ms 980 KB Output is correct
4 Correct 3 ms 1012 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 3 ms 980 KB Output is correct
7 Correct 3 ms 980 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 3 ms 980 KB Output is correct
12 Correct 3 ms 980 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 1004 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 5 ms 980 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 3 ms 724 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 980 KB Output is correct
28 Correct 5 ms 1108 KB Output is correct
29 Correct 2 ms 980 KB Output is correct
30 Correct 4 ms 1108 KB Output is correct
31 Correct 4 ms 1108 KB Output is correct
32 Correct 4 ms 1108 KB Output is correct
33 Correct 4 ms 1108 KB Output is correct
34 Correct 4 ms 1108 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 2 ms 596 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 6 ms 1492 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 5 ms 1492 KB Output is correct
43 Correct 6 ms 1492 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 170 ms 17144 KB Output is correct
46 Correct 49 ms 10924 KB Output is correct
47 Correct 184 ms 18704 KB Output is correct
48 Correct 177 ms 18624 KB Output is correct
49 Correct 35 ms 8404 KB Output is correct
50 Correct 244 ms 23376 KB Output is correct
51 Correct 187 ms 18652 KB Output is correct
52 Correct 45 ms 8464 KB Output is correct
53 Correct 36 ms 8364 KB Output is correct
54 Correct 5 ms 3056 KB Output is correct
55 Correct 272 ms 23268 KB Output is correct
56 Correct 21 ms 5716 KB Output is correct
57 Correct 38 ms 8412 KB Output is correct
58 Correct 41 ms 10932 KB Output is correct
59 Correct 13 ms 5700 KB Output is correct
60 Correct 21 ms 5688 KB Output is correct
61 Correct 44 ms 10980 KB Output is correct
62 Correct 31 ms 8416 KB Output is correct
63 Correct 53 ms 12312 KB Output is correct
64 Correct 14 ms 5716 KB Output is correct
65 Correct 92 ms 14976 KB Output is correct
66 Correct 29 ms 8416 KB Output is correct
67 Correct 60 ms 12296 KB Output is correct
68 Correct 86 ms 14272 KB Output is correct
69 Correct 84 ms 14916 KB Output is correct
70 Correct 28 ms 8444 KB Output is correct
71 Correct 94 ms 14336 KB Output is correct
72 Correct 62 ms 11852 KB Output is correct
73 Correct 157 ms 16648 KB Output is correct
74 Correct 24 ms 8340 KB Output is correct
75 Correct 31 ms 6844 KB Output is correct
76 Correct 79 ms 11928 KB Output is correct
77 Correct 137 ms 16656 KB Output is correct
78 Correct 52 ms 8432 KB Output is correct
79 Correct 37 ms 6700 KB Output is correct
80 Correct 15 ms 3512 KB Output is correct
81 Correct 57 ms 8492 KB Output is correct
82 Correct 74 ms 13672 KB Output is correct
83 Correct 15 ms 3536 KB Output is correct
84 Correct 97 ms 13744 KB Output is correct