#include<bitset>
#include<algorithm>
#include<iostream>
#include<set>
#include<vector>
using namespace std;
const int N = 3e5 + 123;
set<int>g[N];
vector<int>vec;
int s[N];
vector<int>can;
int em[N];
#define cerr if(false) cerr
int was[N];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, k;
cin >> n >> k;
for (int i = 0 ; i < n ; ++ i) {
cin >> s[i];
for (int j = 0 ; j < s[i] ; ++ j) {
int x;
cin >> x;
g[i].insert(x);
}
if ((int)g[i].size() <= k) {
was[i] = 1;
can.emplace_back(i);
}
}
int ans = 0;
for (int i : can) {
vec = {i};
for (auto it : g[i]) vec.emplace_back(it);
sort(vec.begin(), vec.end());
vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
int m = vec.size();
for (int x = 0 ; x < m ; ++ x) em[x] = 0;
for (int x = 0 ; x < m ; ++ x) {
em[x] |= 1 << x;
for (int y = 0 ; y < m ; ++ y) {
if (g[vec[x]].count(vec[y])) em[x] |= 1 << y;
}
}
for (int mask = 0 ; mask < 1 << m ; ++ mask) {
bool ok = true;
for (int x = 0 ; x < m ; ++ x) {
if (mask >> x & 1) {
if ((mask & em[x]) != mask) ok = false;
}
}
if (ok) ans = max(ans, __builtin_popcount(mask));
}
for (int v : vec) g[v].erase(i);
for (int v : vec) if ((int)g[v].size() <= k && !was[v]) was[v] = 1, can.emplace_back(v);
g[i].clear();
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14420 KB |
Output is correct |
2 |
Correct |
8 ms |
14420 KB |
Output is correct |
3 |
Correct |
13 ms |
14960 KB |
Output is correct |
4 |
Correct |
12 ms |
14932 KB |
Output is correct |
5 |
Correct |
13 ms |
14876 KB |
Output is correct |
6 |
Correct |
11 ms |
14860 KB |
Output is correct |
7 |
Correct |
10 ms |
14932 KB |
Output is correct |
8 |
Correct |
9 ms |
14420 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14420 KB |
Output is correct |
2 |
Correct |
8 ms |
14420 KB |
Output is correct |
3 |
Correct |
13 ms |
14960 KB |
Output is correct |
4 |
Correct |
12 ms |
14932 KB |
Output is correct |
5 |
Correct |
13 ms |
14876 KB |
Output is correct |
6 |
Correct |
11 ms |
14860 KB |
Output is correct |
7 |
Correct |
10 ms |
14932 KB |
Output is correct |
8 |
Correct |
9 ms |
14420 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14536 KB |
Output is correct |
11 |
Correct |
10 ms |
14932 KB |
Output is correct |
12 |
Correct |
11 ms |
14932 KB |
Output is correct |
13 |
Correct |
7 ms |
14420 KB |
Output is correct |
14 |
Correct |
10 ms |
14976 KB |
Output is correct |
15 |
Correct |
8 ms |
14420 KB |
Output is correct |
16 |
Correct |
10 ms |
14932 KB |
Output is correct |
17 |
Correct |
8 ms |
14364 KB |
Output is correct |
18 |
Correct |
12 ms |
14940 KB |
Output is correct |
19 |
Correct |
10 ms |
14516 KB |
Output is correct |
20 |
Correct |
10 ms |
14676 KB |
Output is correct |
21 |
Correct |
9 ms |
14636 KB |
Output is correct |
22 |
Correct |
9 ms |
14420 KB |
Output is correct |
23 |
Correct |
11 ms |
15060 KB |
Output is correct |
24 |
Correct |
8 ms |
14524 KB |
Output is correct |
25 |
Correct |
13 ms |
15060 KB |
Output is correct |
26 |
Correct |
10 ms |
14932 KB |
Output is correct |
27 |
Correct |
10 ms |
14964 KB |
Output is correct |
28 |
Correct |
13 ms |
14948 KB |
Output is correct |
29 |
Correct |
12 ms |
14924 KB |
Output is correct |
30 |
Correct |
12 ms |
15060 KB |
Output is correct |
31 |
Correct |
11 ms |
15060 KB |
Output is correct |
32 |
Correct |
11 ms |
15060 KB |
Output is correct |
33 |
Correct |
15 ms |
15132 KB |
Output is correct |
34 |
Correct |
11 ms |
15060 KB |
Output is correct |
35 |
Correct |
9 ms |
14784 KB |
Output is correct |
36 |
Correct |
9 ms |
14676 KB |
Output is correct |
37 |
Correct |
10 ms |
14712 KB |
Output is correct |
38 |
Correct |
9 ms |
14676 KB |
Output is correct |
39 |
Correct |
9 ms |
14676 KB |
Output is correct |
40 |
Correct |
12 ms |
15432 KB |
Output is correct |
41 |
Correct |
8 ms |
14676 KB |
Output is correct |
42 |
Correct |
12 ms |
15316 KB |
Output is correct |
43 |
Correct |
12 ms |
15436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14420 KB |
Output is correct |
2 |
Correct |
8 ms |
14420 KB |
Output is correct |
3 |
Correct |
8 ms |
14420 KB |
Output is correct |
4 |
Correct |
7 ms |
14420 KB |
Output is correct |
5 |
Correct |
8 ms |
14372 KB |
Output is correct |
6 |
Correct |
9 ms |
14420 KB |
Output is correct |
7 |
Correct |
8 ms |
14432 KB |
Output is correct |
8 |
Correct |
8 ms |
14420 KB |
Output is correct |
9 |
Correct |
8 ms |
14440 KB |
Output is correct |
10 |
Correct |
8 ms |
14420 KB |
Output is correct |
11 |
Correct |
473 ms |
36120 KB |
Output is correct |
12 |
Correct |
7 ms |
14420 KB |
Output is correct |
13 |
Correct |
488 ms |
36036 KB |
Output is correct |
14 |
Correct |
8 ms |
14420 KB |
Output is correct |
15 |
Correct |
492 ms |
36068 KB |
Output is correct |
16 |
Correct |
527 ms |
36040 KB |
Output is correct |
17 |
Correct |
524 ms |
36156 KB |
Output is correct |
18 |
Correct |
488 ms |
36044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14420 KB |
Output is correct |
2 |
Correct |
8 ms |
14420 KB |
Output is correct |
3 |
Correct |
13 ms |
14960 KB |
Output is correct |
4 |
Correct |
12 ms |
14932 KB |
Output is correct |
5 |
Correct |
13 ms |
14876 KB |
Output is correct |
6 |
Correct |
11 ms |
14860 KB |
Output is correct |
7 |
Correct |
10 ms |
14932 KB |
Output is correct |
8 |
Correct |
9 ms |
14420 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14536 KB |
Output is correct |
11 |
Correct |
10 ms |
14932 KB |
Output is correct |
12 |
Correct |
11 ms |
14932 KB |
Output is correct |
13 |
Correct |
7 ms |
14420 KB |
Output is correct |
14 |
Correct |
10 ms |
14976 KB |
Output is correct |
15 |
Correct |
8 ms |
14420 KB |
Output is correct |
16 |
Correct |
10 ms |
14932 KB |
Output is correct |
17 |
Correct |
8 ms |
14364 KB |
Output is correct |
18 |
Correct |
12 ms |
14940 KB |
Output is correct |
19 |
Correct |
10 ms |
14516 KB |
Output is correct |
20 |
Correct |
10 ms |
14676 KB |
Output is correct |
21 |
Correct |
9 ms |
14636 KB |
Output is correct |
22 |
Correct |
9 ms |
14420 KB |
Output is correct |
23 |
Correct |
11 ms |
15060 KB |
Output is correct |
24 |
Correct |
8 ms |
14524 KB |
Output is correct |
25 |
Correct |
13 ms |
15060 KB |
Output is correct |
26 |
Correct |
10 ms |
14932 KB |
Output is correct |
27 |
Correct |
10 ms |
14964 KB |
Output is correct |
28 |
Correct |
13 ms |
14948 KB |
Output is correct |
29 |
Correct |
12 ms |
14924 KB |
Output is correct |
30 |
Correct |
12 ms |
15060 KB |
Output is correct |
31 |
Correct |
11 ms |
15060 KB |
Output is correct |
32 |
Correct |
11 ms |
15060 KB |
Output is correct |
33 |
Correct |
15 ms |
15132 KB |
Output is correct |
34 |
Correct |
11 ms |
15060 KB |
Output is correct |
35 |
Correct |
9 ms |
14784 KB |
Output is correct |
36 |
Correct |
9 ms |
14676 KB |
Output is correct |
37 |
Correct |
10 ms |
14712 KB |
Output is correct |
38 |
Correct |
9 ms |
14676 KB |
Output is correct |
39 |
Correct |
9 ms |
14676 KB |
Output is correct |
40 |
Correct |
12 ms |
15432 KB |
Output is correct |
41 |
Correct |
8 ms |
14676 KB |
Output is correct |
42 |
Correct |
12 ms |
15316 KB |
Output is correct |
43 |
Correct |
12 ms |
15436 KB |
Output is correct |
44 |
Correct |
31 ms |
16340 KB |
Output is correct |
45 |
Correct |
7 ms |
14420 KB |
Output is correct |
46 |
Incorrect |
17 ms |
15364 KB |
Output isn't correct |
47 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14420 KB |
Output is correct |
2 |
Correct |
8 ms |
14420 KB |
Output is correct |
3 |
Correct |
13 ms |
14960 KB |
Output is correct |
4 |
Correct |
12 ms |
14932 KB |
Output is correct |
5 |
Correct |
13 ms |
14876 KB |
Output is correct |
6 |
Correct |
11 ms |
14860 KB |
Output is correct |
7 |
Correct |
10 ms |
14932 KB |
Output is correct |
8 |
Correct |
9 ms |
14420 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14536 KB |
Output is correct |
11 |
Correct |
10 ms |
14932 KB |
Output is correct |
12 |
Correct |
11 ms |
14932 KB |
Output is correct |
13 |
Correct |
7 ms |
14420 KB |
Output is correct |
14 |
Correct |
10 ms |
14976 KB |
Output is correct |
15 |
Correct |
8 ms |
14420 KB |
Output is correct |
16 |
Correct |
10 ms |
14932 KB |
Output is correct |
17 |
Correct |
8 ms |
14364 KB |
Output is correct |
18 |
Correct |
12 ms |
14940 KB |
Output is correct |
19 |
Correct |
10 ms |
14516 KB |
Output is correct |
20 |
Correct |
10 ms |
14676 KB |
Output is correct |
21 |
Correct |
9 ms |
14636 KB |
Output is correct |
22 |
Correct |
9 ms |
14420 KB |
Output is correct |
23 |
Correct |
11 ms |
15060 KB |
Output is correct |
24 |
Correct |
8 ms |
14524 KB |
Output is correct |
25 |
Correct |
13 ms |
15060 KB |
Output is correct |
26 |
Correct |
10 ms |
14932 KB |
Output is correct |
27 |
Correct |
10 ms |
14964 KB |
Output is correct |
28 |
Correct |
13 ms |
14948 KB |
Output is correct |
29 |
Correct |
12 ms |
14924 KB |
Output is correct |
30 |
Correct |
12 ms |
15060 KB |
Output is correct |
31 |
Correct |
11 ms |
15060 KB |
Output is correct |
32 |
Correct |
11 ms |
15060 KB |
Output is correct |
33 |
Correct |
15 ms |
15132 KB |
Output is correct |
34 |
Correct |
11 ms |
15060 KB |
Output is correct |
35 |
Correct |
9 ms |
14784 KB |
Output is correct |
36 |
Correct |
9 ms |
14676 KB |
Output is correct |
37 |
Correct |
10 ms |
14712 KB |
Output is correct |
38 |
Correct |
9 ms |
14676 KB |
Output is correct |
39 |
Correct |
9 ms |
14676 KB |
Output is correct |
40 |
Correct |
12 ms |
15432 KB |
Output is correct |
41 |
Correct |
8 ms |
14676 KB |
Output is correct |
42 |
Correct |
12 ms |
15316 KB |
Output is correct |
43 |
Correct |
12 ms |
15436 KB |
Output is correct |
44 |
Correct |
9 ms |
14420 KB |
Output is correct |
45 |
Runtime error |
138 ms |
58664 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |