# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
239317 | dsjong | Political Development (BOI17_politicaldevelopment) | C++14 | 2850 ms | 66200 KiB |
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;
int sz[100005];
bool good[2000];
vector<int>adj[100005];
map<pair<int, int>, int> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
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 x;
cin>>x;
adj[i].push_back(x);
mp[{i, x}]=true;
}
sz[i]=d;
}
int ans=1;
for(int t=0;t<n;t++){
int mini=INT_MAX, idx;
for(int i=0;i<n;i++){
if(sz[i]<mini){
mini=sz[i];
idx=i;
}
}
// cout<<idx<<endl;
vector<int>v;
for(int i:adj[idx]){
if(sz[i]<=n) v.push_back(i);
}
int m=v.size();
good[0]=true;
for(int i=1;i<(1<<m);i++){
int lg=log2(i);
int x=i-(1<<lg);
if(good[x]){
bool b=true;
for(int j=0;j<m;j++){
if((1<<j)&x)
if(j!=lg) b&=mp[{v[j], v[lg]}];
}
good[i]=b;
}
else good[i]=false;
if(good[i]){
int cnt=0;
for(int j=0;j<m;j++){
if((1<<j)&i) cnt++;
}
ans=max(ans, cnt+1);
}
}
sz[idx]=INT_MAX;
for(int i:adj[idx]) sz[i]--;
}
cout<<ans;
}
Compilation message (stderr)
# | 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... |