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 rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
#define nmax 301
const ll mod = 998244353;
int n, m, k, viz[50001], deg[50001], ans;
set<int> g[50001];
set <pi> edg;
priority_queue<pi, vector<pi>, greater<pi>> pq;
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
//cin>>n;for(int i=1; i<=n; i++){int x; cin>>x; pq.push(x);};while(!pq.empty()){int x=pq.top(); pq.pop(); cout<<x<<" ";}
cin>>n>>k;
for(int i=0; i<n; i++){
cin>>deg[i];
pq.push({deg[i], i});
for(int j=1; j<=deg[i]; j++){
int x;
cin>>x;
g[i].insert(x);
edg.insert({i, x});
}
}
//for(pi i: edg){ cout<<i.x<<" "<<i.y<<"\n";}
//cout<<"\n";
while(true){
//cout<<"xd"<<endl;
while(!pq.empty() && viz[pq.top().x]) pq.pop();
if(pq.empty()) break;
int a=pq.top().y, d=pq.top().x;
pq.pop();
deg[a]=0;
viz[a]=1;
vi v={a};
for(int i : g[a]){
if(!viz[i]){
deg[i]--;
pq.push({deg[i], i});
v.pb(i);
}
}
//assert(v.size()<=10);
//for(int i : v) cout<<i<<" "; cout<<endl;
bool adj[11][11];
for(int i=0; i<v.size(); i++){
//a[i][j]=0;
for(int j=0; j<v.size(); j++){
if(i!=j && edg.find({v[i], v[j]})!=edg.end()){
adj[i][j]=1;
}
else adj[i][j]=0;
}
}
for(int mask=1; mask<(1<<v.size()); mask+=2){
bool ctrl=1;
int cnt=0;
for(int i=0; i<v.size(); i++){
if((mask>>i)%2==0) continue;
cnt++;
for(int j=0; j<v.size(); j++){
if((mask>>j)%2==0) continue;
if(i!=j && adj[i][j]==0) ctrl=0;
}
}
if(ctrl) ans=max(ans, cnt);
}
}
cout<<ans<<endl;
}
Compilation message (stderr)
politicaldevelopment.cpp: In function 'int32_t main()':
politicaldevelopment.cpp:55:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
politicaldevelopment.cpp:57:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<v.size(); j++){
~^~~~~~~~~
politicaldevelopment.cpp:67:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
politicaldevelopment.cpp:70:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<v.size(); j++){
~^~~~~~~~~
politicaldevelopment.cpp:40:27: warning: unused variable 'd' [-Wunused-variable]
int a=pq.top().y, d=pq.top().x;
^
# | 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... |