Submission #841299

# Submission time Handle Problem Language Result Execution time Memory
841299 2023-09-01T13:03:01 Z serifefedartar Political Development (BOI17_politicaldevelopment) C++17
16 / 100
3000 ms 28048 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];
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 >> 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();
		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);
			deg[u]--;

			if (deg[u] < K)
				q.push(u);
		}
	}
	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 0 ms 212 KB Output is correct
3 Correct 2 ms 980 KB Output is correct
4 Correct 2 ms 980 KB Output is correct
5 Correct 2 ms 960 KB Output is correct
6 Correct 2 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 2 ms 980 KB Output is correct
4 Correct 2 ms 980 KB Output is correct
5 Correct 2 ms 960 KB Output is correct
6 Correct 2 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 2 ms 980 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 980 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 980 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 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 4 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 3 ms 1108 KB Output is correct
29 Correct 3 ms 980 KB Output is correct
30 Correct 3 ms 1236 KB Output is correct
31 Correct 3 ms 1108 KB Output is correct
32 Correct 3 ms 1236 KB Output is correct
33 Correct 3 ms 1108 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 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 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 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 Execution timed out 3077 ms 28048 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 2 ms 980 KB Output is correct
4 Correct 2 ms 980 KB Output is correct
5 Correct 2 ms 960 KB Output is correct
6 Correct 2 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 2 ms 980 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 980 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 980 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 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 4 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 3 ms 1108 KB Output is correct
29 Correct 3 ms 980 KB Output is correct
30 Correct 3 ms 1236 KB Output is correct
31 Correct 3 ms 1108 KB Output is correct
32 Correct 3 ms 1236 KB Output is correct
33 Correct 3 ms 1108 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 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 19 ms 2516 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 148 ms 1608 KB Output is correct
47 Execution timed out 3010 ms 3348 KB Time limit exceeded
48 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 2 ms 980 KB Output is correct
4 Correct 2 ms 980 KB Output is correct
5 Correct 2 ms 960 KB Output is correct
6 Correct 2 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 2 ms 980 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 980 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 2 ms 980 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 980 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 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 4 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 3 ms 1108 KB Output is correct
29 Correct 3 ms 980 KB Output is correct
30 Correct 3 ms 1236 KB Output is correct
31 Correct 3 ms 1108 KB Output is correct
32 Correct 3 ms 1236 KB Output is correct
33 Correct 3 ms 1108 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 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 1 ms 212 KB Output is correct
45 Correct 105 ms 16896 KB Output is correct
46 Correct 48 ms 10196 KB Output is correct
47 Execution timed out 3064 ms 18996 KB Time limit exceeded
48 Halted 0 ms 0 KB -