Submission #841252

# Submission time Handle Problem Language Result Execution time Memory
841252 2023-09-01T12:07:53 Z serifefedartar Political Development (BOI17_politicaldevelopment) C++17
16 / 100
3000 ms 22120 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<vector<int>> graph;
vector<pair<int,int>> degree;
set<pair<int,int>> edges;
bool omit[MAXN];
int main() {
	fast
	int N, K, x, D; 
	cin >> N >> K;
 
	graph = vector<vector<int>>(N, vector<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].push_back(i);
			graph[i].push_back(x);
			edges.insert({min(x, i), max(x, i)});
			degree[i].f++;
			degree[x].f++;
		}
	}
	sort(degree.begin(), degree.end());
 
	int ans = 1;
	for (auto u : degree) {
		int node = u.s;
 
		vector<int> adj;
		for (auto p : graph[node]) {
			if (!omit[p])
				adj.push_back(p);
		}
		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 (edges.count({min(adj[j], u), max(adj[j], u)}) == 0)
							check = false;
					}
					taken.push_back(adj[j]);
				}
			}
 
			if (check)
				ans = max(ans, k + 1);
		}
		omit[node] = true;
	}
	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 8 ms 852 KB Output is correct
4 Correct 4 ms 952 KB Output is correct
5 Correct 4 ms 952 KB Output is correct
6 Correct 100 ms 852 KB Output is correct
7 Correct 99 ms 944 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 468 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 8 ms 852 KB Output is correct
4 Correct 4 ms 952 KB Output is correct
5 Correct 4 ms 952 KB Output is correct
6 Correct 100 ms 852 KB Output is correct
7 Correct 99 ms 944 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 4 ms 952 KB Output is correct
12 Correct 4 ms 852 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 872 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 105 ms 940 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 101 ms 940 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 12 ms 980 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 11 ms 1012 KB Output is correct
26 Correct 10 ms 852 KB Output is correct
27 Correct 9 ms 852 KB Output is correct
28 Correct 11 ms 852 KB Output is correct
29 Correct 9 ms 876 KB Output is correct
30 Correct 11 ms 1024 KB Output is correct
31 Correct 14 ms 1024 KB Output is correct
32 Correct 10 ms 980 KB Output is correct
33 Correct 14 ms 1028 KB Output is correct
34 Correct 14 ms 1020 KB Output is correct
35 Correct 7 ms 596 KB Output is correct
36 Correct 7 ms 596 KB Output is correct
37 Correct 7 ms 596 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 5 ms 468 KB Output is correct
40 Correct 70 ms 1236 KB Output is correct
41 Correct 6 ms 468 KB Output is correct
42 Correct 56 ms 1236 KB Output is correct
43 Correct 99 ms 1264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3066 ms 22120 KB Time limit exceeded
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 8 ms 852 KB Output is correct
4 Correct 4 ms 952 KB Output is correct
5 Correct 4 ms 952 KB Output is correct
6 Correct 100 ms 852 KB Output is correct
7 Correct 99 ms 944 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 4 ms 952 KB Output is correct
12 Correct 4 ms 852 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 872 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 105 ms 940 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 101 ms 940 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 12 ms 980 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 11 ms 1012 KB Output is correct
26 Correct 10 ms 852 KB Output is correct
27 Correct 9 ms 852 KB Output is correct
28 Correct 11 ms 852 KB Output is correct
29 Correct 9 ms 876 KB Output is correct
30 Correct 11 ms 1024 KB Output is correct
31 Correct 14 ms 1024 KB Output is correct
32 Correct 10 ms 980 KB Output is correct
33 Correct 14 ms 1028 KB Output is correct
34 Correct 14 ms 1020 KB Output is correct
35 Correct 7 ms 596 KB Output is correct
36 Correct 7 ms 596 KB Output is correct
37 Correct 7 ms 596 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 5 ms 468 KB Output is correct
40 Correct 70 ms 1236 KB Output is correct
41 Correct 6 ms 468 KB Output is correct
42 Correct 56 ms 1236 KB Output is correct
43 Correct 99 ms 1264 KB Output is correct
44 Execution timed out 3076 ms 1876 KB Time limit exceeded
45 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 8 ms 852 KB Output is correct
4 Correct 4 ms 952 KB Output is correct
5 Correct 4 ms 952 KB Output is correct
6 Correct 100 ms 852 KB Output is correct
7 Correct 99 ms 944 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 4 ms 952 KB Output is correct
12 Correct 4 ms 852 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 872 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 105 ms 940 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 101 ms 940 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 12 ms 980 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 11 ms 1012 KB Output is correct
26 Correct 10 ms 852 KB Output is correct
27 Correct 9 ms 852 KB Output is correct
28 Correct 11 ms 852 KB Output is correct
29 Correct 9 ms 876 KB Output is correct
30 Correct 11 ms 1024 KB Output is correct
31 Correct 14 ms 1024 KB Output is correct
32 Correct 10 ms 980 KB Output is correct
33 Correct 14 ms 1028 KB Output is correct
34 Correct 14 ms 1020 KB Output is correct
35 Correct 7 ms 596 KB Output is correct
36 Correct 7 ms 596 KB Output is correct
37 Correct 7 ms 596 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 5 ms 468 KB Output is correct
40 Correct 70 ms 1236 KB Output is correct
41 Correct 6 ms 468 KB Output is correct
42 Correct 56 ms 1236 KB Output is correct
43 Correct 99 ms 1264 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Execution timed out 3043 ms 13480 KB Time limit exceeded
46 Halted 0 ms 0 KB -