Submission #542728

# Submission time Handle Problem Language Result Execution time Memory
542728 2022-03-27T18:07:30 Z skittles1412 Political Development (BOI17_politicaldevelopment) C++17
4 / 100
5 ms 1108 KB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
	cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
	cerr << t << " | ";
	dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                           \
	cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
		 << ": ";                                          \
	dbgh(__VA_ARGS__)
#else
#define cerr   \
	if (false) \
	cerr
#define dbg(...)
#endif

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

template <typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

bool on(int msk, int bit) {
	return (msk >> bit) & 1;
}

int clique(const vector<vector<bool>>& graph) {
	int n = sz(graph);
	int dp[1 << n];
	for (int i = (1 << n) - 1; i >= 0; i--) {
		dp[i] = __builtin_popcount(i);
		for (int j = 0; j < n; j++) {
			if (!on(i, j)) {
				for (int k = 0; k < n; k++) {
					if (on(i, k) && !graph[j][k]) {
						goto loop;
					}
				}
				dp[i] = max(dp[i], dp[i | (1 << j)]);
			loop:;
			}
		}
	}
	return dp[0];
}

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> graph[n];
	for (auto& a : graph) {
		int m;
		cin >> m;
		a.resize(m);
		for (auto& b : a) {
			cin >> b;
		}
		sort(begin(a), end(a));
	}
	bool del[n] {};
	int deg[n] {};
	for (int i = 0; i < n; i++) {
		deg[i] = sz(graph[i]);
	}
	min_pq<pair<int, int>> pq;
	for (int i = 0; i < n; i++) {
		pq.emplace(deg[i], i);
	}
	int ans = 0;
	for (int _ = 0; _ < n; _++) {
		int u;
		while (true) {
			auto [d, v] = pq.top();
			pq.pop();
			if (deg[v] == d) {
				u = v;
				break;
			}
		}
		dbg(u);
		del[u] = true;
		for (auto& a : graph[u]) {
			deg[a]--;
			pq.emplace(deg[a], a);
		}
		vector<int> cur = {u};
		for (auto& a : graph[u]) {
			if (!del[a]) {
				dbg(a);
				cur.push_back(a);
			}
		}
		int m = sz(cur);
		vector<vector<bool>> cg(m, vector<bool> (m));
		for (int i = 0; i < m; i++) {
			for (int j = i + 1; j < m; j++) {
				if (binary_search(begin(graph[cur[i]]), end(graph[cur[i]]), cur[j])) {
					cg[i][j] = cg[j][i] = true;
				}
			}
		}
		ans = max(ans, clique(cg));
	}
	cout << ans << endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cin.exceptions(ios::failbit);
	solve();
}
# 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 3 ms 724 KB Output is correct
4 Correct 4 ms 852 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 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 3 ms 724 KB Output is correct
4 Correct 4 ms 852 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
12 Correct 4 ms 844 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 5 ms 800 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 0 ms 324 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Incorrect 3 ms 716 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 320 KB Output isn't correct
4 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 3 ms 724 KB Output is correct
4 Correct 4 ms 852 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
12 Correct 4 ms 844 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 5 ms 800 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 0 ms 324 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Incorrect 3 ms 716 KB Output isn't correct
21 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 3 ms 724 KB Output is correct
4 Correct 4 ms 852 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
12 Correct 4 ms 844 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 5 ms 800 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 0 ms 324 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Incorrect 3 ms 716 KB Output isn't correct
21 Halted 0 ms 0 KB -