#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 400005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
#define rep(c, a, b) for(c = a; c <= b; c++)
ll n, t, T, a[N][11], m[N], k, b[N], answer, vip[6000][6000];
set <int> s;
void solve(int x,int cnt) {
if(cnt > k) return;
if(x == n+1) {
ll p = sz(s);
answer = max(answer,p);
return;
}
bool tr = 0;
for(auto i : s) {
if(!vip[i][x]) tr = 1;
}
if(!tr){
b[x] = 1;
s.insert(x);
solve(x + 1,cnt + 1);
s.erase(*(--s.end()));
}
b[x] = 0;
solve(x + 1,cnt);
}
int main () {
ios::sync_with_stdio(0);cin.tie(0);
cin >> n >> k;
for(int i = 1; i <= n; i++) {
cin >> m[i];
for(int j = 1; j <= m[i]; j++) {
int x;
cin >>x;
x++;
vip[i][x] = 1;
}
}
solve(1,0);
cout << answer << '\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... |