Submission #631023

# Submission time Handle Problem Language Result Execution time Memory
631023 2022-08-17T14:38:35 Z hollwo_pelw Political Development (BOI17_politicaldevelopment) C++17
16 / 100
238 ms 26076 KB
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/trie_policy.hpp>
// #include <ext/rope>

using namespace std;
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;

void Hollwo_Pelw();

signed main(){
#ifndef hollwo_pelw_local
	if (fopen(".inp", "r"))
		assert(freopen(".inp", "r", stdin)), assert(freopen(".out", "w", stdout));
#else
	using namespace chrono;
	auto start = steady_clock::now();
#endif
	cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
	int testcases = 1;
	// cin >> testcases;
	for (int test = 1; test <= testcases; test++){
		// cout << "Case #" << test << ": ";
		Hollwo_Pelw();
	}
#ifdef hollwo_pelw_local
	auto end = steady_clock::now();
	cout << "\nExecution time : " << duration_cast<milliseconds> (end - start).count() << "[ms]" << endl;
#endif
}

const int N = 5e4 + 5;

int n, k, con[10], dp[1 << 10], res;
set<int> adj[N];

void Hollwo_Pelw(){
	cin >> n >> k;
	set<pair<int, int>> pq;
	for (int i = 0, j, d; i < n; i++) {
		for (cin >> d; d --; )
			cin >> j, adj[i].insert(j);
	}

	for (int i = 0; i < n; i++)
		pq.emplace(adj[i].size(), i);

	while (!pq.empty()) {
		int u = pq.begin() -> second; pq.erase(pq.begin());

		vector<int> f;
		for (int v : adj[u]) {
			f.push_back(v);
			pq.erase({adj[v].size(), v});

			adj[v].erase(u);

			pq.emplace(adj[v].size(), v);
		}

		int m = f.size();
		assert(m <= k);

		fill(dp, dp + (1 << m), 0);

		for (int i = 0; i < m; i++)
			for (int j = 0; j < m; j++)
				if (adj[f[i]].count(f[j]) || j == i)
					con[i] |= 1 << j;

		dp[0] = 1;

		for (int i = 0; i < m; i++) {
			for (int j = 1 << i; j < 2 << i; j++)
				dp[j] = dp[j ^ 1 << i] & ((con[i] & j) == j);
		}

		for (int j = 0; j < 1 << m; j++) if (dp[j])
			res = max(res, 1 + __builtin_popcount(j));
	}

	cout << res << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 6 ms 3324 KB Output is correct
4 Correct 6 ms 3428 KB Output is correct
5 Correct 8 ms 3412 KB Output is correct
6 Correct 6 ms 3444 KB Output is correct
7 Correct 6 ms 3412 KB Output is correct
8 Correct 2 ms 2900 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 3 ms 2900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 6 ms 3324 KB Output is correct
4 Correct 6 ms 3428 KB Output is correct
5 Correct 8 ms 3412 KB Output is correct
6 Correct 6 ms 3444 KB Output is correct
7 Correct 6 ms 3412 KB Output is correct
8 Correct 2 ms 2900 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 3 ms 2900 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 6 ms 3368 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 6 ms 3412 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 7 ms 3412 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 6 ms 3328 KB Output is correct
19 Correct 3 ms 2900 KB Output is correct
20 Correct 4 ms 3156 KB Output is correct
21 Correct 5 ms 3072 KB Output is correct
22 Correct 2 ms 2900 KB Output is correct
23 Correct 7 ms 3568 KB Output is correct
24 Correct 2 ms 2812 KB Output is correct
25 Correct 8 ms 3452 KB Output is correct
26 Correct 6 ms 3448 KB Output is correct
27 Correct 6 ms 3412 KB Output is correct
28 Correct 8 ms 3448 KB Output is correct
29 Correct 5 ms 3412 KB Output is correct
30 Correct 7 ms 3496 KB Output is correct
31 Correct 7 ms 3540 KB Output is correct
32 Correct 7 ms 3584 KB Output is correct
33 Correct 7 ms 3580 KB Output is correct
34 Correct 7 ms 3540 KB Output is correct
35 Correct 5 ms 3036 KB Output is correct
36 Correct 4 ms 3076 KB Output is correct
37 Correct 4 ms 3028 KB Output is correct
38 Correct 4 ms 2900 KB Output is correct
39 Correct 4 ms 2900 KB Output is correct
40 Correct 12 ms 3924 KB Output is correct
41 Correct 4 ms 2900 KB Output is correct
42 Correct 10 ms 3960 KB Output is correct
43 Correct 10 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2900 KB Output is correct
2 Incorrect 1 ms 2644 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 6 ms 3324 KB Output is correct
4 Correct 6 ms 3428 KB Output is correct
5 Correct 8 ms 3412 KB Output is correct
6 Correct 6 ms 3444 KB Output is correct
7 Correct 6 ms 3412 KB Output is correct
8 Correct 2 ms 2900 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 3 ms 2900 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 6 ms 3368 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 6 ms 3412 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 7 ms 3412 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 6 ms 3328 KB Output is correct
19 Correct 3 ms 2900 KB Output is correct
20 Correct 4 ms 3156 KB Output is correct
21 Correct 5 ms 3072 KB Output is correct
22 Correct 2 ms 2900 KB Output is correct
23 Correct 7 ms 3568 KB Output is correct
24 Correct 2 ms 2812 KB Output is correct
25 Correct 8 ms 3452 KB Output is correct
26 Correct 6 ms 3448 KB Output is correct
27 Correct 6 ms 3412 KB Output is correct
28 Correct 8 ms 3448 KB Output is correct
29 Correct 5 ms 3412 KB Output is correct
30 Correct 7 ms 3496 KB Output is correct
31 Correct 7 ms 3540 KB Output is correct
32 Correct 7 ms 3584 KB Output is correct
33 Correct 7 ms 3580 KB Output is correct
34 Correct 7 ms 3540 KB Output is correct
35 Correct 5 ms 3036 KB Output is correct
36 Correct 4 ms 3076 KB Output is correct
37 Correct 4 ms 3028 KB Output is correct
38 Correct 4 ms 2900 KB Output is correct
39 Correct 4 ms 2900 KB Output is correct
40 Correct 12 ms 3924 KB Output is correct
41 Correct 4 ms 2900 KB Output is correct
42 Correct 10 ms 3960 KB Output is correct
43 Correct 10 ms 3924 KB Output is correct
44 Correct 16 ms 4984 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 11 ms 3908 KB Output is correct
47 Incorrect 22 ms 4948 KB Output isn't correct
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 6 ms 3324 KB Output is correct
4 Correct 6 ms 3428 KB Output is correct
5 Correct 8 ms 3412 KB Output is correct
6 Correct 6 ms 3444 KB Output is correct
7 Correct 6 ms 3412 KB Output is correct
8 Correct 2 ms 2900 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 3 ms 2900 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 6 ms 3368 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 6 ms 3412 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 7 ms 3412 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 6 ms 3328 KB Output is correct
19 Correct 3 ms 2900 KB Output is correct
20 Correct 4 ms 3156 KB Output is correct
21 Correct 5 ms 3072 KB Output is correct
22 Correct 2 ms 2900 KB Output is correct
23 Correct 7 ms 3568 KB Output is correct
24 Correct 2 ms 2812 KB Output is correct
25 Correct 8 ms 3452 KB Output is correct
26 Correct 6 ms 3448 KB Output is correct
27 Correct 6 ms 3412 KB Output is correct
28 Correct 8 ms 3448 KB Output is correct
29 Correct 5 ms 3412 KB Output is correct
30 Correct 7 ms 3496 KB Output is correct
31 Correct 7 ms 3540 KB Output is correct
32 Correct 7 ms 3584 KB Output is correct
33 Correct 7 ms 3580 KB Output is correct
34 Correct 7 ms 3540 KB Output is correct
35 Correct 5 ms 3036 KB Output is correct
36 Correct 4 ms 3076 KB Output is correct
37 Correct 4 ms 3028 KB Output is correct
38 Correct 4 ms 2900 KB Output is correct
39 Correct 4 ms 2900 KB Output is correct
40 Correct 12 ms 3924 KB Output is correct
41 Correct 4 ms 2900 KB Output is correct
42 Correct 10 ms 3960 KB Output is correct
43 Correct 10 ms 3924 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 199 ms 20828 KB Output is correct
46 Correct 95 ms 12980 KB Output is correct
47 Correct 189 ms 20804 KB Output is correct
48 Correct 238 ms 20804 KB Output is correct
49 Correct 55 ms 10276 KB Output is correct
50 Correct 195 ms 26076 KB Output is correct
51 Incorrect 194 ms 20816 KB Output isn't correct
52 Halted 0 ms 0 KB -