Submission #825240

# Submission time Handle Problem Language Result Execution time Memory
825240 2023-08-14T16:06:47 Z QwertyPi Political Development (BOI17_politicaldevelopment) C++14
0 / 100
2 ms 2772 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 5e4 + 11;
const int MAXK = 10;

bool done[MAXN];
set<int> G[MAXN];

template<class T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int ans = 1;

bool can(const vector<int>& v){
	for(int i = 0; i < v.size(); i++){
		for(int j = i + 1; j < v.size(); j++){
			if(!G[i].count(j)) return false;
		}
	}
	return true;
}

void check(const vector<int>& v){
	bool ok = can(v);
	if(ok) ans = max(ans, (int) v.size());
}

int32_t main(){
	int n, k; cin >> n >> k;
	for(int i = 0; i < n; i++){
		int d; cin >> d;
		for(int j = 0; j < d; j++){
			int v; cin >> v; G[i].insert(v);
		}
	}

	min_priority_queue<pair<int, int>> pq;
	for(int i = 1; i <= n; i++){
		pq.push({G[i].size(), i});
	}

	while(!pq.empty()){
		auto [d, v] = pq.top(); pq.pop();
		if(G[v].size() != d || done[v]) continue;
		done[v] = true;

		vector<int> adj {G[v].begin(), G[v].end()};
		for(int i = 0; i < (1 << d); i++){
			vector<int> ch {v};
			for(int j = 0; j < d; j++){
				if(i & (1 << j)) ch.push_back(adj[j]);
			}
			check(ch);
		}
		for(auto u : G[v]){
			if(G[u].count(v)) G[u].erase(v);
			pq.push({G[u].size(), u});
		}
	}
	cout << ans << endl;
}

Compilation message

politicaldevelopment.cpp: In function 'bool can(const std::vector<int>&)':
politicaldevelopment.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 0; i < v.size(); i++){
      |                 ~~^~~~~~~~~~
politicaldevelopment.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int j = i + 1; j < v.size(); j++){
      |                      ~~^~~~~~~~~~
politicaldevelopment.cpp: In function 'int32_t main()':
politicaldevelopment.cpp:44:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |   auto [d, v] = pq.top(); pq.pop();
      |        ^
politicaldevelopment.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'} [-Wsign-compare]
   45 |   if(G[v].size() != d || done[v]) continue;
      |      ~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2772 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 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -