Submission #596875

# Submission time Handle Problem Language Result Execution time Memory
596875 2022-07-15T08:28:40 Z SeDunion Political Development (BOI17_politicaldevelopment) C++17
39 / 100
503 ms 60416 KB
#include<bitset>
#include<iostream>
#include<set>
#include<vector>

using namespace std;

const int N = 3e5 + 123;

set<int>g[N];
vector<int>vec;

int s[N];

vector<int>can;

int em[N];

#define cerr if(false) cerr

int was[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> s[i];
		for (int j = 0 ; j < s[i] ; ++ j) {
			int x;
			cin >> x;
			g[i].insert(x);
		}
		if (s[i] <= k) {
			was[i] = 1;
			can.emplace_back(i);
		}
	}
	int ans = 0;
	for (int i : can) {
		vec = {i};
		for (auto it : g[i]) vec.emplace_back(it);
		cerr << i << " | ";
		for (int v : vec) cerr << v << " ";
		cerr << endl;
		int m = vec.size();
		for (int x = 0 ; x < m ; ++ x) em[x] = 0;
		for (int x = 0 ; x < m ; ++ x) {
			em[x] |= 1 << x;
			for (int y = 0 ; y < m ; ++ y) {
				if (g[vec[x]].count(vec[y])) em[x] |= 1 << y;
			}
		}
		for (int mask = 0 ; mask < 1 << m ; ++ mask) {
			bool ok = true;
			for (int x = 0 ; x < m ; ++ x) {
				if (mask >> x & 1) {
					if ((mask & em[x]) != mask) ok = false;
				}
			}
			if (ok) ans = max(ans, __builtin_popcount(mask));
		}
		for (int v : vec) g[v].erase(i);
		for (int v : vec) if ((int)g[v].size() <= k && !was[v]) was[v] = 1, can.emplace_back(v);
		g[i].clear();
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14436 KB Output is correct
2 Correct 9 ms 14452 KB Output is correct
3 Correct 10 ms 14968 KB Output is correct
4 Correct 11 ms 15040 KB Output is correct
5 Correct 10 ms 14932 KB Output is correct
6 Correct 10 ms 14932 KB Output is correct
7 Correct 10 ms 14932 KB Output is correct
8 Correct 8 ms 14548 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14436 KB Output is correct
2 Correct 9 ms 14452 KB Output is correct
3 Correct 10 ms 14968 KB Output is correct
4 Correct 11 ms 15040 KB Output is correct
5 Correct 10 ms 14932 KB Output is correct
6 Correct 10 ms 14932 KB Output is correct
7 Correct 10 ms 14932 KB Output is correct
8 Correct 8 ms 14548 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14444 KB Output is correct
11 Correct 10 ms 14932 KB Output is correct
12 Correct 13 ms 14956 KB Output is correct
13 Correct 7 ms 14420 KB Output is correct
14 Correct 10 ms 14932 KB Output is correct
15 Correct 7 ms 14420 KB Output is correct
16 Correct 10 ms 14932 KB Output is correct
17 Correct 7 ms 14420 KB Output is correct
18 Correct 12 ms 14932 KB Output is correct
19 Correct 8 ms 14440 KB Output is correct
20 Correct 9 ms 14676 KB Output is correct
21 Correct 9 ms 14700 KB Output is correct
22 Correct 8 ms 14564 KB Output is correct
23 Correct 12 ms 15088 KB Output is correct
24 Correct 11 ms 14548 KB Output is correct
25 Correct 11 ms 15088 KB Output is correct
26 Correct 10 ms 15064 KB Output is correct
27 Correct 10 ms 14932 KB Output is correct
28 Correct 13 ms 15088 KB Output is correct
29 Correct 10 ms 15024 KB Output is correct
30 Correct 12 ms 15152 KB Output is correct
31 Correct 10 ms 15204 KB Output is correct
32 Correct 12 ms 15188 KB Output is correct
33 Correct 12 ms 15092 KB Output is correct
34 Correct 12 ms 15188 KB Output is correct
35 Correct 10 ms 14708 KB Output is correct
36 Correct 9 ms 14804 KB Output is correct
37 Correct 10 ms 14804 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 11 ms 14608 KB Output is correct
40 Correct 13 ms 15512 KB Output is correct
41 Correct 9 ms 14676 KB Output is correct
42 Correct 11 ms 15468 KB Output is correct
43 Correct 13 ms 15444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14548 KB Output is correct
2 Correct 10 ms 14440 KB Output is correct
3 Correct 7 ms 14420 KB Output is correct
4 Correct 10 ms 14396 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 7 ms 14420 KB Output is correct
7 Correct 7 ms 14428 KB Output is correct
8 Correct 8 ms 14420 KB Output is correct
9 Correct 8 ms 14432 KB Output is correct
10 Correct 8 ms 14392 KB Output is correct
11 Correct 483 ms 38828 KB Output is correct
12 Correct 7 ms 14420 KB Output is correct
13 Correct 493 ms 38780 KB Output is correct
14 Correct 8 ms 14372 KB Output is correct
15 Correct 497 ms 38756 KB Output is correct
16 Correct 503 ms 38720 KB Output is correct
17 Correct 479 ms 38776 KB Output is correct
18 Correct 477 ms 38728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14436 KB Output is correct
2 Correct 9 ms 14452 KB Output is correct
3 Correct 10 ms 14968 KB Output is correct
4 Correct 11 ms 15040 KB Output is correct
5 Correct 10 ms 14932 KB Output is correct
6 Correct 10 ms 14932 KB Output is correct
7 Correct 10 ms 14932 KB Output is correct
8 Correct 8 ms 14548 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14444 KB Output is correct
11 Correct 10 ms 14932 KB Output is correct
12 Correct 13 ms 14956 KB Output is correct
13 Correct 7 ms 14420 KB Output is correct
14 Correct 10 ms 14932 KB Output is correct
15 Correct 7 ms 14420 KB Output is correct
16 Correct 10 ms 14932 KB Output is correct
17 Correct 7 ms 14420 KB Output is correct
18 Correct 12 ms 14932 KB Output is correct
19 Correct 8 ms 14440 KB Output is correct
20 Correct 9 ms 14676 KB Output is correct
21 Correct 9 ms 14700 KB Output is correct
22 Correct 8 ms 14564 KB Output is correct
23 Correct 12 ms 15088 KB Output is correct
24 Correct 11 ms 14548 KB Output is correct
25 Correct 11 ms 15088 KB Output is correct
26 Correct 10 ms 15064 KB Output is correct
27 Correct 10 ms 14932 KB Output is correct
28 Correct 13 ms 15088 KB Output is correct
29 Correct 10 ms 15024 KB Output is correct
30 Correct 12 ms 15152 KB Output is correct
31 Correct 10 ms 15204 KB Output is correct
32 Correct 12 ms 15188 KB Output is correct
33 Correct 12 ms 15092 KB Output is correct
34 Correct 12 ms 15188 KB Output is correct
35 Correct 10 ms 14708 KB Output is correct
36 Correct 9 ms 14804 KB Output is correct
37 Correct 10 ms 14804 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 11 ms 14608 KB Output is correct
40 Correct 13 ms 15512 KB Output is correct
41 Correct 9 ms 14676 KB Output is correct
42 Correct 11 ms 15468 KB Output is correct
43 Correct 13 ms 15444 KB Output is correct
44 Correct 33 ms 16560 KB Output is correct
45 Correct 7 ms 14420 KB Output is correct
46 Incorrect 13 ms 15672 KB Output isn't correct
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14436 KB Output is correct
2 Correct 9 ms 14452 KB Output is correct
3 Correct 10 ms 14968 KB Output is correct
4 Correct 11 ms 15040 KB Output is correct
5 Correct 10 ms 14932 KB Output is correct
6 Correct 10 ms 14932 KB Output is correct
7 Correct 10 ms 14932 KB Output is correct
8 Correct 8 ms 14548 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14444 KB Output is correct
11 Correct 10 ms 14932 KB Output is correct
12 Correct 13 ms 14956 KB Output is correct
13 Correct 7 ms 14420 KB Output is correct
14 Correct 10 ms 14932 KB Output is correct
15 Correct 7 ms 14420 KB Output is correct
16 Correct 10 ms 14932 KB Output is correct
17 Correct 7 ms 14420 KB Output is correct
18 Correct 12 ms 14932 KB Output is correct
19 Correct 8 ms 14440 KB Output is correct
20 Correct 9 ms 14676 KB Output is correct
21 Correct 9 ms 14700 KB Output is correct
22 Correct 8 ms 14564 KB Output is correct
23 Correct 12 ms 15088 KB Output is correct
24 Correct 11 ms 14548 KB Output is correct
25 Correct 11 ms 15088 KB Output is correct
26 Correct 10 ms 15064 KB Output is correct
27 Correct 10 ms 14932 KB Output is correct
28 Correct 13 ms 15088 KB Output is correct
29 Correct 10 ms 15024 KB Output is correct
30 Correct 12 ms 15152 KB Output is correct
31 Correct 10 ms 15204 KB Output is correct
32 Correct 12 ms 15188 KB Output is correct
33 Correct 12 ms 15092 KB Output is correct
34 Correct 12 ms 15188 KB Output is correct
35 Correct 10 ms 14708 KB Output is correct
36 Correct 9 ms 14804 KB Output is correct
37 Correct 10 ms 14804 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 11 ms 14608 KB Output is correct
40 Correct 13 ms 15512 KB Output is correct
41 Correct 9 ms 14676 KB Output is correct
42 Correct 11 ms 15468 KB Output is correct
43 Correct 13 ms 15444 KB Output is correct
44 Correct 8 ms 14420 KB Output is correct
45 Runtime error 127 ms 60416 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -