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;
const int mxN = 50000;
using S = bitset<mxN>;
S g[mxN];
int ans = 0;
void find_max(S can, int has) {
ans = max(has, ans);
while (can.any()) {
int cur = (int)can._Find_first();
can.reset(cur);
S nxt_s = can & g[cur];
if ((int)nxt_s.count()+has+1 > ans) {
find_max(nxt_s, has+1);
}
}
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int n, k; cin >> n >> k;
for (int i = 0; i < n; ++i) {
int s; cin >> s;
g[i].set(i);
for (int ss = 0; ss < s; ++ss) {
int j; cin >> j;
g[i].set(j);
}
}
/*
for (int i = 0; i < n; ++i)
cerr << g[i] << '\n'; // */
S init;
for (int i = 0; i < n; ++i) init.set(i);
find_max(init, 0);
cout << ans << '\n';
}
# | 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... |