#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(){
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=0;
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
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:57:16: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
sz[idx]=INT_MAX;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
45 ms |
3456 KB |
Output is correct |
4 |
Correct |
47 ms |
3456 KB |
Output is correct |
5 |
Correct |
43 ms |
3456 KB |
Output is correct |
6 |
Correct |
45 ms |
3576 KB |
Output is correct |
7 |
Correct |
44 ms |
3456 KB |
Output is correct |
8 |
Incorrect |
36 ms |
2688 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
45 ms |
3456 KB |
Output is correct |
4 |
Correct |
47 ms |
3456 KB |
Output is correct |
5 |
Correct |
43 ms |
3456 KB |
Output is correct |
6 |
Correct |
45 ms |
3576 KB |
Output is correct |
7 |
Correct |
44 ms |
3456 KB |
Output is correct |
8 |
Incorrect |
36 ms |
2688 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
45 ms |
3456 KB |
Output is correct |
4 |
Correct |
47 ms |
3456 KB |
Output is correct |
5 |
Correct |
43 ms |
3456 KB |
Output is correct |
6 |
Correct |
45 ms |
3576 KB |
Output is correct |
7 |
Correct |
44 ms |
3456 KB |
Output is correct |
8 |
Incorrect |
36 ms |
2688 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
45 ms |
3456 KB |
Output is correct |
4 |
Correct |
47 ms |
3456 KB |
Output is correct |
5 |
Correct |
43 ms |
3456 KB |
Output is correct |
6 |
Correct |
45 ms |
3576 KB |
Output is correct |
7 |
Correct |
44 ms |
3456 KB |
Output is correct |
8 |
Incorrect |
36 ms |
2688 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |