Submission #841291

# Submission time Handle Problem Language Result Execution time Memory
841291 2023-09-01T12:55:44 Z serifefedartar Political Development (BOI17_politicaldevelopment) C++17
16 / 100
3000 ms 41456 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;
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++) {
		cin >> D;
		for (int j = 0; j < D; j++) {
			cin >> x;
			graph[x].insert(i);
			graph[i].insert(x);
		}

		if (D < K)
			q.push(i);
	}
 
	int ans = 1;
	while (!q.empty()) {
		int node = q.front();
		q.pop();
		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;
			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);
			if (graph[u].size() < K)
				q.push(u);
		}
	}
	cout << ans << "\n";
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:65:24: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |    if (graph[u].size() < K)
      |        ~~~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 980 KB Output is correct
4 Correct 3 ms 980 KB Output is correct
5 Correct 3 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 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 980 KB Output is correct
4 Correct 3 ms 980 KB Output is correct
5 Correct 3 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 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 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 3 ms 980 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 3 ms 980 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 788 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 3 ms 1108 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 3 ms 980 KB Output is correct
28 Correct 3 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 3 ms 1108 KB Output is correct
32 Correct 5 ms 1108 KB Output is correct
33 Correct 4 ms 1160 KB Output is correct
34 Correct 3 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 632 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 5 ms 1492 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 5 ms 1492 KB Output is correct
43 Correct 5 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 Execution timed out 3068 ms 32160 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 980 KB Output is correct
4 Correct 3 ms 980 KB Output is correct
5 Correct 3 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 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 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 3 ms 980 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 3 ms 980 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 788 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 3 ms 1108 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 3 ms 980 KB Output is correct
28 Correct 3 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 3 ms 1108 KB Output is correct
32 Correct 5 ms 1108 KB Output is correct
33 Correct 4 ms 1160 KB Output is correct
34 Correct 3 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 632 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 5 ms 1492 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 5 ms 1492 KB Output is correct
43 Correct 5 ms 1492 KB Output is correct
44 Correct 26 ms 2644 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 37 ms 2004 KB Output is correct
47 Execution timed out 3072 ms 16356 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 980 KB Output is correct
4 Correct 3 ms 980 KB Output is correct
5 Correct 3 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 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 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 3 ms 980 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 3 ms 980 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 788 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 3 ms 1108 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 3 ms 1108 KB Output is correct
26 Correct 3 ms 1108 KB Output is correct
27 Correct 3 ms 980 KB Output is correct
28 Correct 3 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 3 ms 1108 KB Output is correct
32 Correct 5 ms 1108 KB Output is correct
33 Correct 4 ms 1160 KB Output is correct
34 Correct 3 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 632 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 5 ms 1492 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 5 ms 1492 KB Output is correct
43 Correct 5 ms 1492 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 143 ms 16704 KB Output is correct
46 Correct 46 ms 9920 KB Output is correct
47 Execution timed out 3100 ms 41456 KB Time limit exceeded
48 Halted 0 ms 0 KB -