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