This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 50000;
int n, k;
int deg[N];
vector<int> g[N];
bitset<N> yes[N];
bool can(vector<int>&v){
for(int i = 0;i < v.size(); i++){
for(int j = i +1;j < v.size(); j++){
if(yes[v[i]][v[j]] == 0) return false;
}
}
return true;
}
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int> > > pq;
for(int i = 0;i < n; i++){
int sz; cin >> sz;
deg[i] = sz;
pq.push({deg[i], i});
for(int j = 0;j < sz; j++){
int x; cin >> x;
yes[i][x] = 1;
g[i].push_back(x);
}
}
int ans = 1;
vector<int> used(n, 0);
while(true){
while(!pq.empty() && used[pq.top().ss]) pq.pop();
if(pq.empty()) break;
int v = pq.top().ss;
pq.pop();
used[v] = 1;
deg[v] = 0;
vector<int> vert = {v};
for(int to : g[v]){
if(used[to]) continue;
deg[to]--;
pq.push({deg[to], to});
vert.push_back(to);
}
bool adj[11][11] = {};
for(int i = 0;i < vert.size(); i++){
adj[i][i] = 1;
for(int j = 0; j < vert.size(); j++){
if(i != j && yes[vert[i]][vert[j]]){
adj[i][j] = 1;
}
}
}
for(int mask = 1; mask < (1<<vert.size()); mask++){
int ok = 1, cnt = 0;
for(int i = 0;i < vert.size() && ok; i++){
if(!(mask & (1<<i))) continue;
cnt++;
for(int j = 0;j < vert.size(); j++){
if(mask & (1<<j)){
if(adj[i][j] == 0){
ok = 0;
break;
}
}
}
}
if(ok) ans = max(ans, cnt);
}
}
cout << ans;
return 0;
}
Compilation message (stderr)
politicaldevelopment.cpp: In function 'bool can(std::vector<int>&)':
politicaldevelopment.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i = 0;i < v.size(); i++){
| ~~^~~~~~~~~~
politicaldevelopment.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int j = i +1;j < v.size(); j++){
| ~~^~~~~~~~~~
politicaldevelopment.cpp: At global scope:
politicaldevelopment.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
23 | main(){
| ^~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i = 0;i < vert.size(); i++){
| ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:57:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int j = 0; j < vert.size(); j++){
| ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:65:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int i = 0;i < vert.size() && ok; i++){
| ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:68:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for(int j = 0;j < vert.size(); j++){
| ~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |