//Dedicated to my love,ivaziva
#include <bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define pb push_back
#define me(a, x) memset(a, x, sizeof(a))
#define vi vector<int>
#define i128 __int128
using namespace std;
const int N = 5e4 + 7;
int n, k;
bitset<N> g[N];
vector<vi> vec[15];
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> k;
L(i, 0, n - 1) {
int d; cin >> d;
L(j, 1, d) {
int v; cin >> v;
g[min(v, i)][max(v, i)] = true;
}
vec[1].pb({i});
}
bitset<N> bs;
int ans = 1;
while(true) {
for(vi a : vec[ans]) {
bool ok = false;
for(int x : a) {
if(!ok) {
bs = g[x];
ok = true;
} else bs &= g[x];
}
for(int j = bs._Find_first(); j < n; j = bs._Find_next(j)) {
vi nxt = a;
nxt.pb(j);
vec[ans + 1].pb(nxt);
}
}
ans++;
if(!sz(vec[ans])) break;
}
cout << ans - 1 << '\n';
return 0;
}
# | 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... |