Submission #841283

# Submission time Handle Problem Language Result Execution time Memory
841283 2023-09-01T12:45:00 Z serifefedartar Political Development (BOI17_politicaldevelopment) C++17
16 / 100
3000 ms 32500 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({i, x});
			edges.insert({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++) {
			vector<int> taken;
			bool check = true;
			for (int j = 0; j < degree; j++) {
				if ((1<<j) & msk) {
					for (auto p : taken) {
						if (edges.count({adj[j], p}) == 0)
							check = false;
					}
					taken.push_back(adj[j]);
				}
			}
 
			if (check)
				ans = max(ans, (int)taken.size() + 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 1152 KB Output is correct
4 Correct 5 ms 1104 KB Output is correct
5 Correct 5 ms 1184 KB Output is correct
6 Correct 94 ms 1176 KB Output is correct
7 Correct 93 ms 1108 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 1152 KB Output is correct
4 Correct 5 ms 1104 KB Output is correct
5 Correct 5 ms 1184 KB Output is correct
6 Correct 94 ms 1176 KB Output is correct
7 Correct 93 ms 1108 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 5 ms 1108 KB Output is correct
12 Correct 5 ms 1144 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 5 ms 1188 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 103 ms 1188 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 106 ms 1168 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 14 ms 1272 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 13 ms 1192 KB Output is correct
26 Correct 11 ms 1224 KB Output is correct
27 Correct 9 ms 1108 KB Output is correct
28 Correct 11 ms 1108 KB Output is correct
29 Correct 9 ms 1000 KB Output is correct
30 Correct 11 ms 1320 KB Output is correct
31 Correct 14 ms 1340 KB Output is correct
32 Correct 11 ms 1232 KB Output is correct
33 Correct 18 ms 1336 KB Output is correct
34 Correct 13 ms 1328 KB Output is correct
35 Correct 7 ms 836 KB Output is correct
36 Correct 7 ms 816 KB Output is correct
37 Correct 7 ms 824 KB Output is correct
38 Correct 5 ms 596 KB Output is correct
39 Correct 6 ms 596 KB Output is correct
40 Correct 83 ms 1840 KB Output is correct
41 Correct 5 ms 596 KB Output is correct
42 Correct 56 ms 1744 KB Output is correct
43 Correct 86 ms 1748 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 2 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 2 ms 256 KB Output is correct
11 Execution timed out 3051 ms 32500 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 1152 KB Output is correct
4 Correct 5 ms 1104 KB Output is correct
5 Correct 5 ms 1184 KB Output is correct
6 Correct 94 ms 1176 KB Output is correct
7 Correct 93 ms 1108 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 5 ms 1108 KB Output is correct
12 Correct 5 ms 1144 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 5 ms 1188 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 103 ms 1188 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 106 ms 1168 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 14 ms 1272 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 13 ms 1192 KB Output is correct
26 Correct 11 ms 1224 KB Output is correct
27 Correct 9 ms 1108 KB Output is correct
28 Correct 11 ms 1108 KB Output is correct
29 Correct 9 ms 1000 KB Output is correct
30 Correct 11 ms 1320 KB Output is correct
31 Correct 14 ms 1340 KB Output is correct
32 Correct 11 ms 1232 KB Output is correct
33 Correct 18 ms 1336 KB Output is correct
34 Correct 13 ms 1328 KB Output is correct
35 Correct 7 ms 836 KB Output is correct
36 Correct 7 ms 816 KB Output is correct
37 Correct 7 ms 824 KB Output is correct
38 Correct 5 ms 596 KB Output is correct
39 Correct 6 ms 596 KB Output is correct
40 Correct 83 ms 1840 KB Output is correct
41 Correct 5 ms 596 KB Output is correct
42 Correct 56 ms 1744 KB Output is correct
43 Correct 86 ms 1748 KB Output is correct
44 Execution timed out 3071 ms 2772 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 1152 KB Output is correct
4 Correct 5 ms 1104 KB Output is correct
5 Correct 5 ms 1184 KB Output is correct
6 Correct 94 ms 1176 KB Output is correct
7 Correct 93 ms 1108 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 5 ms 1108 KB Output is correct
12 Correct 5 ms 1144 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 5 ms 1188 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 103 ms 1188 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 106 ms 1168 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 14 ms 1272 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 13 ms 1192 KB Output is correct
26 Correct 11 ms 1224 KB Output is correct
27 Correct 9 ms 1108 KB Output is correct
28 Correct 11 ms 1108 KB Output is correct
29 Correct 9 ms 1000 KB Output is correct
30 Correct 11 ms 1320 KB Output is correct
31 Correct 14 ms 1340 KB Output is correct
32 Correct 11 ms 1232 KB Output is correct
33 Correct 18 ms 1336 KB Output is correct
34 Correct 13 ms 1328 KB Output is correct
35 Correct 7 ms 836 KB Output is correct
36 Correct 7 ms 816 KB Output is correct
37 Correct 7 ms 824 KB Output is correct
38 Correct 5 ms 596 KB Output is correct
39 Correct 6 ms 596 KB Output is correct
40 Correct 83 ms 1840 KB Output is correct
41 Correct 5 ms 596 KB Output is correct
42 Correct 56 ms 1744 KB Output is correct
43 Correct 86 ms 1748 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Execution timed out 3074 ms 20600 KB Time limit exceeded
46 Halted 0 ms 0 KB -