#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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
30 ms |
21992 KB |
Output is correct |
4 |
Correct |
32 ms |
21512 KB |
Output is correct |
5 |
Correct |
34 ms |
21340 KB |
Output is correct |
6 |
Correct |
30 ms |
21592 KB |
Output is correct |
7 |
Correct |
28 ms |
21340 KB |
Output is correct |
8 |
Correct |
21 ms |
20316 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
20 ms |
20564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
30 ms |
21992 KB |
Output is correct |
4 |
Correct |
32 ms |
21512 KB |
Output is correct |
5 |
Correct |
34 ms |
21340 KB |
Output is correct |
6 |
Correct |
30 ms |
21592 KB |
Output is correct |
7 |
Correct |
28 ms |
21340 KB |
Output is correct |
8 |
Correct |
21 ms |
20316 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
20 ms |
20564 KB |
Output is correct |
11 |
Correct |
29 ms |
21340 KB |
Output is correct |
12 |
Correct |
30 ms |
21484 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
25 ms |
21176 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
35 ms |
21596 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
27 ms |
21524 KB |
Output is correct |
19 |
Correct |
20 ms |
20560 KB |
Output is correct |
20 |
Correct |
28 ms |
21580 KB |
Output is correct |
21 |
Correct |
20 ms |
21596 KB |
Output is correct |
22 |
Correct |
19 ms |
20564 KB |
Output is correct |
23 |
Correct |
28 ms |
22104 KB |
Output is correct |
24 |
Correct |
19 ms |
20572 KB |
Output is correct |
25 |
Correct |
34 ms |
22108 KB |
Output is correct |
26 |
Correct |
32 ms |
21852 KB |
Output is correct |
27 |
Correct |
30 ms |
22104 KB |
Output is correct |
28 |
Correct |
32 ms |
22108 KB |
Output is correct |
29 |
Correct |
29 ms |
21984 KB |
Output is correct |
30 |
Correct |
34 ms |
22108 KB |
Output is correct |
31 |
Correct |
34 ms |
22312 KB |
Output is correct |
32 |
Correct |
33 ms |
21976 KB |
Output is correct |
33 |
Correct |
34 ms |
22108 KB |
Output is correct |
34 |
Correct |
34 ms |
22108 KB |
Output is correct |
35 |
Correct |
17 ms |
10844 KB |
Output is correct |
36 |
Correct |
17 ms |
10840 KB |
Output is correct |
37 |
Correct |
19 ms |
10992 KB |
Output is correct |
38 |
Correct |
11 ms |
5604 KB |
Output is correct |
39 |
Correct |
13 ms |
5596 KB |
Output is correct |
40 |
Correct |
37 ms |
22364 KB |
Output is correct |
41 |
Correct |
16 ms |
5468 KB |
Output is correct |
42 |
Correct |
37 ms |
22392 KB |
Output is correct |
43 |
Correct |
37 ms |
22364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
20316 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
971 ms |
309152 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
421 ms |
309244 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1000 ms |
309172 KB |
Output is correct |
16 |
Correct |
575 ms |
309076 KB |
Output is correct |
17 |
Correct |
522 ms |
309076 KB |
Output is correct |
18 |
Correct |
649 ms |
309332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
30 ms |
21992 KB |
Output is correct |
4 |
Correct |
32 ms |
21512 KB |
Output is correct |
5 |
Correct |
34 ms |
21340 KB |
Output is correct |
6 |
Correct |
30 ms |
21592 KB |
Output is correct |
7 |
Correct |
28 ms |
21340 KB |
Output is correct |
8 |
Correct |
21 ms |
20316 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
20 ms |
20564 KB |
Output is correct |
11 |
Correct |
29 ms |
21340 KB |
Output is correct |
12 |
Correct |
30 ms |
21484 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
25 ms |
21176 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
35 ms |
21596 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
27 ms |
21524 KB |
Output is correct |
19 |
Correct |
20 ms |
20560 KB |
Output is correct |
20 |
Correct |
28 ms |
21580 KB |
Output is correct |
21 |
Correct |
20 ms |
21596 KB |
Output is correct |
22 |
Correct |
19 ms |
20564 KB |
Output is correct |
23 |
Correct |
28 ms |
22104 KB |
Output is correct |
24 |
Correct |
19 ms |
20572 KB |
Output is correct |
25 |
Correct |
34 ms |
22108 KB |
Output is correct |
26 |
Correct |
32 ms |
21852 KB |
Output is correct |
27 |
Correct |
30 ms |
22104 KB |
Output is correct |
28 |
Correct |
32 ms |
22108 KB |
Output is correct |
29 |
Correct |
29 ms |
21984 KB |
Output is correct |
30 |
Correct |
34 ms |
22108 KB |
Output is correct |
31 |
Correct |
34 ms |
22312 KB |
Output is correct |
32 |
Correct |
33 ms |
21976 KB |
Output is correct |
33 |
Correct |
34 ms |
22108 KB |
Output is correct |
34 |
Correct |
34 ms |
22108 KB |
Output is correct |
35 |
Correct |
17 ms |
10844 KB |
Output is correct |
36 |
Correct |
17 ms |
10840 KB |
Output is correct |
37 |
Correct |
19 ms |
10992 KB |
Output is correct |
38 |
Correct |
11 ms |
5604 KB |
Output is correct |
39 |
Correct |
13 ms |
5596 KB |
Output is correct |
40 |
Correct |
37 ms |
22364 KB |
Output is correct |
41 |
Correct |
16 ms |
5468 KB |
Output is correct |
42 |
Correct |
37 ms |
22392 KB |
Output is correct |
43 |
Correct |
37 ms |
22364 KB |
Output is correct |
44 |
Correct |
23 ms |
23128 KB |
Output is correct |
45 |
Correct |
1 ms |
348 KB |
Output is correct |
46 |
Correct |
34 ms |
22504 KB |
Output is correct |
47 |
Correct |
57 ms |
22872 KB |
Output is correct |
48 |
Correct |
37 ms |
22364 KB |
Output is correct |
49 |
Correct |
58 ms |
22872 KB |
Output is correct |
50 |
Correct |
57 ms |
22876 KB |
Output is correct |
51 |
Correct |
90 ms |
23644 KB |
Output is correct |
52 |
Correct |
32 ms |
21848 KB |
Output is correct |
53 |
Correct |
133 ms |
23520 KB |
Output is correct |
54 |
Correct |
100 ms |
23788 KB |
Output is correct |
55 |
Correct |
28 ms |
21592 KB |
Output is correct |
56 |
Correct |
39 ms |
21848 KB |
Output is correct |
57 |
Correct |
20 ms |
20316 KB |
Output is correct |
58 |
Correct |
129 ms |
23388 KB |
Output is correct |
59 |
Correct |
24 ms |
22616 KB |
Output is correct |
60 |
Correct |
28 ms |
21596 KB |
Output is correct |
61 |
Correct |
23 ms |
22616 KB |
Output is correct |
62 |
Correct |
23 ms |
22620 KB |
Output is correct |
63 |
Correct |
26 ms |
23128 KB |
Output is correct |
64 |
Correct |
25 ms |
23128 KB |
Output is correct |
65 |
Correct |
33 ms |
22360 KB |
Output is correct |
66 |
Correct |
23 ms |
22616 KB |
Output is correct |
67 |
Correct |
49 ms |
23132 KB |
Output is correct |
68 |
Correct |
23 ms |
22996 KB |
Output is correct |
69 |
Correct |
36 ms |
22236 KB |
Output is correct |
70 |
Correct |
47 ms |
22876 KB |
Output is correct |
71 |
Correct |
49 ms |
23128 KB |
Output is correct |
72 |
Correct |
45 ms |
23052 KB |
Output is correct |
73 |
Correct |
29 ms |
21852 KB |
Output is correct |
74 |
Correct |
42 ms |
22876 KB |
Output is correct |
75 |
Correct |
58 ms |
23252 KB |
Output is correct |
76 |
Correct |
46 ms |
22620 KB |
Output is correct |
77 |
Correct |
90 ms |
23384 KB |
Output is correct |
78 |
Correct |
31 ms |
21848 KB |
Output is correct |
79 |
Correct |
47 ms |
11100 KB |
Output is correct |
80 |
Correct |
47 ms |
22620 KB |
Output is correct |
81 |
Correct |
96 ms |
23384 KB |
Output is correct |
82 |
Correct |
10 ms |
5468 KB |
Output is correct |
83 |
Correct |
44 ms |
11096 KB |
Output is correct |
84 |
Correct |
52 ms |
23132 KB |
Output is correct |
85 |
Correct |
10 ms |
5468 KB |
Output is correct |
86 |
Correct |
45 ms |
23204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
30 ms |
21992 KB |
Output is correct |
4 |
Correct |
32 ms |
21512 KB |
Output is correct |
5 |
Correct |
34 ms |
21340 KB |
Output is correct |
6 |
Correct |
30 ms |
21592 KB |
Output is correct |
7 |
Correct |
28 ms |
21340 KB |
Output is correct |
8 |
Correct |
21 ms |
20316 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
20 ms |
20564 KB |
Output is correct |
11 |
Correct |
29 ms |
21340 KB |
Output is correct |
12 |
Correct |
30 ms |
21484 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
25 ms |
21176 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
35 ms |
21596 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
27 ms |
21524 KB |
Output is correct |
19 |
Correct |
20 ms |
20560 KB |
Output is correct |
20 |
Correct |
28 ms |
21580 KB |
Output is correct |
21 |
Correct |
20 ms |
21596 KB |
Output is correct |
22 |
Correct |
19 ms |
20564 KB |
Output is correct |
23 |
Correct |
28 ms |
22104 KB |
Output is correct |
24 |
Correct |
19 ms |
20572 KB |
Output is correct |
25 |
Correct |
34 ms |
22108 KB |
Output is correct |
26 |
Correct |
32 ms |
21852 KB |
Output is correct |
27 |
Correct |
30 ms |
22104 KB |
Output is correct |
28 |
Correct |
32 ms |
22108 KB |
Output is correct |
29 |
Correct |
29 ms |
21984 KB |
Output is correct |
30 |
Correct |
34 ms |
22108 KB |
Output is correct |
31 |
Correct |
34 ms |
22312 KB |
Output is correct |
32 |
Correct |
33 ms |
21976 KB |
Output is correct |
33 |
Correct |
34 ms |
22108 KB |
Output is correct |
34 |
Correct |
34 ms |
22108 KB |
Output is correct |
35 |
Correct |
17 ms |
10844 KB |
Output is correct |
36 |
Correct |
17 ms |
10840 KB |
Output is correct |
37 |
Correct |
19 ms |
10992 KB |
Output is correct |
38 |
Correct |
11 ms |
5604 KB |
Output is correct |
39 |
Correct |
13 ms |
5596 KB |
Output is correct |
40 |
Correct |
37 ms |
22364 KB |
Output is correct |
41 |
Correct |
16 ms |
5468 KB |
Output is correct |
42 |
Correct |
37 ms |
22392 KB |
Output is correct |
43 |
Correct |
37 ms |
22364 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
654 ms |
306428 KB |
Output is correct |
46 |
Correct |
428 ms |
296456 KB |
Output is correct |
47 |
Correct |
586 ms |
305840 KB |
Output is correct |
48 |
Correct |
586 ms |
306392 KB |
Output is correct |
49 |
Correct |
281 ms |
270740 KB |
Output is correct |
50 |
Correct |
742 ms |
308816 KB |
Output is correct |
51 |
Correct |
638 ms |
305744 KB |
Output is correct |
52 |
Correct |
337 ms |
265560 KB |
Output is correct |
53 |
Correct |
300 ms |
270676 KB |
Output is correct |
54 |
Correct |
204 ms |
201040 KB |
Output is correct |
55 |
Correct |
852 ms |
308708 KB |
Output is correct |
56 |
Correct |
276 ms |
265304 KB |
Output is correct |
57 |
Correct |
316 ms |
266720 KB |
Output is correct |
58 |
Correct |
254 ms |
300884 KB |
Output is correct |
59 |
Correct |
235 ms |
265556 KB |
Output is correct |
60 |
Correct |
261 ms |
265632 KB |
Output is correct |
61 |
Correct |
253 ms |
301124 KB |
Output is correct |
62 |
Correct |
250 ms |
290988 KB |
Output is correct |
63 |
Correct |
411 ms |
298528 KB |
Output is correct |
64 |
Correct |
258 ms |
265092 KB |
Output is correct |
65 |
Correct |
411 ms |
302328 KB |
Output is correct |
66 |
Correct |
265 ms |
291152 KB |
Output is correct |
67 |
Correct |
455 ms |
298764 KB |
Output is correct |
68 |
Correct |
504 ms |
301904 KB |
Output is correct |
69 |
Correct |
420 ms |
302328 KB |
Output is correct |
70 |
Correct |
380 ms |
290596 KB |
Output is correct |
71 |
Correct |
470 ms |
302160 KB |
Output is correct |
72 |
Correct |
462 ms |
295508 KB |
Output is correct |
73 |
Correct |
723 ms |
306476 KB |
Output is correct |
74 |
Correct |
389 ms |
290896 KB |
Output is correct |
75 |
Correct |
293 ms |
146032 KB |
Output is correct |
76 |
Correct |
424 ms |
292688 KB |
Output is correct |
77 |
Correct |
743 ms |
306536 KB |
Output is correct |
78 |
Correct |
350 ms |
149424 KB |
Output is correct |
79 |
Correct |
269 ms |
145976 KB |
Output is correct |
80 |
Correct |
117 ms |
60240 KB |
Output is correct |
81 |
Correct |
329 ms |
149492 KB |
Output is correct |
82 |
Correct |
518 ms |
305032 KB |
Output is correct |
83 |
Correct |
117 ms |
60508 KB |
Output is correct |
84 |
Correct |
526 ms |
305040 KB |
Output is correct |