#include "bits/stdc++.h"
using namespace std;
#define SZ(s) (int)s.size()
int n, k, ans;
vector <int> vis, v1;
vector <vector <int>> v, a;
void dfs(int x){
ans = max(ans, SZ(v1));
vis[x] = true;
for(auto i : v[x]){
if(vis[i]) continue;
bool tr = 0;
for(auto j : v1){
if(!a[i][j] or !a[j][i]){
tr = 1;
break;
}
}
if(!tr){
v1.push_back(i);
dfs(i);
v1.pop_back();
}
}
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> k;
a.resize(n+1, vector <int> (n+1,0));
v.resize(n+1), vis.resize(n+1,0);
bool tr = 0;
for(int i = 0; i < n; i++){
int d;
cin >> d;
if(d != 0) tr = 1;
while(d--){
int x;
cin >> x;
a[i][x] = true;
v[i].push_back(x);
}
}
for(int i = 0; i < n; i++){
v1.push_back(i);
dfs(i);
v1.pop_back();
}
cout << ans;
}
# | 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... |