#include <bits/stdc++.h>
using namespace std;
const int nx=5e4+5;
int n, k, x, y, res;
set<int> d[nx];
set<pair<int, int>> s;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>k;
for (int i=0; i<n; i++)
{
cin>>x;
for (int j=1; j<=x; j++) cin>>y, d[i].insert(y);
s.insert({d[i].size(), i});
}
while (!s.empty())
{
auto [sz, x]=*s.begin();
//cout<<"debug "<<s.size()<<' '<<sz<<' '<<x<<'\n';
s.erase(s.begin());
vector<int> v;
//cout<<"node ";
for (auto tmp:d[x]) v.push_back(tmp);//cout<<tmp<<' ';
//cout<<'\n';
for (int msk=0; msk<(1<<sz); msk++)
{
vector<int> t;
for (int i=0; i<sz; i++) if (msk&(1<<i)) t.push_back(v[i]);
int cnt=__builtin_popcount(msk);
bool can=1;
for (int i=0; i<cnt; i++) for (int j=i+1; j<cnt; j++) if (d[t[i]].find(t[j])==d[t[i]].end()) can=0;
if (can) res=max(res, cnt+1);
}
for (auto tmp:d[x]) s.erase(make_pair(d[tmp].size(), tmp)), d[tmp].erase(x), s.insert({d[tmp].size(), tmp});
}
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2652 KB |
Output is correct |
3 |
Correct |
3 ms |
3420 KB |
Output is correct |
4 |
Correct |
3 ms |
3420 KB |
Output is correct |
5 |
Correct |
3 ms |
3424 KB |
Output is correct |
6 |
Correct |
3 ms |
3420 KB |
Output is correct |
7 |
Correct |
3 ms |
3332 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
0 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2652 KB |
Output is correct |
3 |
Correct |
3 ms |
3420 KB |
Output is correct |
4 |
Correct |
3 ms |
3420 KB |
Output is correct |
5 |
Correct |
3 ms |
3424 KB |
Output is correct |
6 |
Correct |
3 ms |
3420 KB |
Output is correct |
7 |
Correct |
3 ms |
3332 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
0 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2908 KB |
Output is correct |
11 |
Correct |
4 ms |
3624 KB |
Output is correct |
12 |
Correct |
3 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
3420 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
5 ms |
3396 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
3 ms |
3420 KB |
Output is correct |
19 |
Correct |
1 ms |
2908 KB |
Output is correct |
20 |
Correct |
2 ms |
3272 KB |
Output is correct |
21 |
Correct |
2 ms |
3164 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
4 ms |
3676 KB |
Output is correct |
24 |
Correct |
1 ms |
2908 KB |
Output is correct |
25 |
Correct |
5 ms |
3676 KB |
Output is correct |
26 |
Correct |
4 ms |
3420 KB |
Output is correct |
27 |
Correct |
3 ms |
3420 KB |
Output is correct |
28 |
Correct |
3 ms |
3420 KB |
Output is correct |
29 |
Correct |
3 ms |
3420 KB |
Output is correct |
30 |
Correct |
4 ms |
3676 KB |
Output is correct |
31 |
Correct |
4 ms |
3676 KB |
Output is correct |
32 |
Correct |
6 ms |
3676 KB |
Output is correct |
33 |
Correct |
4 ms |
3676 KB |
Output is correct |
34 |
Correct |
4 ms |
3676 KB |
Output is correct |
35 |
Correct |
2 ms |
3164 KB |
Output is correct |
36 |
Correct |
2 ms |
3164 KB |
Output is correct |
37 |
Correct |
2 ms |
3164 KB |
Output is correct |
38 |
Correct |
2 ms |
2908 KB |
Output is correct |
39 |
Correct |
2 ms |
2908 KB |
Output is correct |
40 |
Correct |
6 ms |
3932 KB |
Output is correct |
41 |
Correct |
2 ms |
2908 KB |
Output is correct |
42 |
Correct |
7 ms |
3932 KB |
Output is correct |
43 |
Correct |
6 ms |
3928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2904 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
0 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2908 KB |
Output is correct |
8 |
Correct |
0 ms |
2652 KB |
Output is correct |
9 |
Correct |
0 ms |
2652 KB |
Output is correct |
10 |
Correct |
0 ms |
2652 KB |
Output is correct |
11 |
Correct |
378 ms |
28876 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
379 ms |
28916 KB |
Output is correct |
14 |
Correct |
1 ms |
2652 KB |
Output is correct |
15 |
Correct |
379 ms |
28852 KB |
Output is correct |
16 |
Correct |
395 ms |
28912 KB |
Output is correct |
17 |
Correct |
436 ms |
28868 KB |
Output is correct |
18 |
Correct |
395 ms |
28912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2652 KB |
Output is correct |
3 |
Correct |
3 ms |
3420 KB |
Output is correct |
4 |
Correct |
3 ms |
3420 KB |
Output is correct |
5 |
Correct |
3 ms |
3424 KB |
Output is correct |
6 |
Correct |
3 ms |
3420 KB |
Output is correct |
7 |
Correct |
3 ms |
3332 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
0 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2908 KB |
Output is correct |
11 |
Correct |
4 ms |
3624 KB |
Output is correct |
12 |
Correct |
3 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
3420 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
5 ms |
3396 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
3 ms |
3420 KB |
Output is correct |
19 |
Correct |
1 ms |
2908 KB |
Output is correct |
20 |
Correct |
2 ms |
3272 KB |
Output is correct |
21 |
Correct |
2 ms |
3164 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
4 ms |
3676 KB |
Output is correct |
24 |
Correct |
1 ms |
2908 KB |
Output is correct |
25 |
Correct |
5 ms |
3676 KB |
Output is correct |
26 |
Correct |
4 ms |
3420 KB |
Output is correct |
27 |
Correct |
3 ms |
3420 KB |
Output is correct |
28 |
Correct |
3 ms |
3420 KB |
Output is correct |
29 |
Correct |
3 ms |
3420 KB |
Output is correct |
30 |
Correct |
4 ms |
3676 KB |
Output is correct |
31 |
Correct |
4 ms |
3676 KB |
Output is correct |
32 |
Correct |
6 ms |
3676 KB |
Output is correct |
33 |
Correct |
4 ms |
3676 KB |
Output is correct |
34 |
Correct |
4 ms |
3676 KB |
Output is correct |
35 |
Correct |
2 ms |
3164 KB |
Output is correct |
36 |
Correct |
2 ms |
3164 KB |
Output is correct |
37 |
Correct |
2 ms |
3164 KB |
Output is correct |
38 |
Correct |
2 ms |
2908 KB |
Output is correct |
39 |
Correct |
2 ms |
2908 KB |
Output is correct |
40 |
Correct |
6 ms |
3932 KB |
Output is correct |
41 |
Correct |
2 ms |
2908 KB |
Output is correct |
42 |
Correct |
7 ms |
3932 KB |
Output is correct |
43 |
Correct |
6 ms |
3928 KB |
Output is correct |
44 |
Correct |
39 ms |
4952 KB |
Output is correct |
45 |
Correct |
0 ms |
2648 KB |
Output is correct |
46 |
Correct |
6 ms |
3928 KB |
Output is correct |
47 |
Correct |
17 ms |
4956 KB |
Output is correct |
48 |
Correct |
7 ms |
3932 KB |
Output is correct |
49 |
Correct |
17 ms |
5120 KB |
Output is correct |
50 |
Correct |
18 ms |
4956 KB |
Output is correct |
51 |
Correct |
250 ms |
7000 KB |
Output is correct |
52 |
Correct |
4 ms |
3416 KB |
Output is correct |
53 |
Correct |
484 ms |
7516 KB |
Output is correct |
54 |
Correct |
509 ms |
7512 KB |
Output is correct |
55 |
Correct |
4 ms |
3420 KB |
Output is correct |
56 |
Correct |
3 ms |
3420 KB |
Output is correct |
57 |
Correct |
1 ms |
2908 KB |
Output is correct |
58 |
Correct |
438 ms |
7672 KB |
Output is correct |
59 |
Correct |
5 ms |
3932 KB |
Output is correct |
60 |
Correct |
3 ms |
3416 KB |
Output is correct |
61 |
Correct |
5 ms |
4088 KB |
Output is correct |
62 |
Correct |
6 ms |
3932 KB |
Output is correct |
63 |
Correct |
39 ms |
4884 KB |
Output is correct |
64 |
Correct |
21 ms |
4700 KB |
Output is correct |
65 |
Correct |
5 ms |
3928 KB |
Output is correct |
66 |
Correct |
5 ms |
3932 KB |
Output is correct |
67 |
Correct |
40 ms |
5468 KB |
Output is correct |
68 |
Correct |
20 ms |
4696 KB |
Output is correct |
69 |
Correct |
5 ms |
3932 KB |
Output is correct |
70 |
Correct |
16 ms |
4900 KB |
Output is correct |
71 |
Correct |
41 ms |
5468 KB |
Output is correct |
72 |
Correct |
32 ms |
5212 KB |
Output is correct |
73 |
Correct |
3 ms |
3416 KB |
Output is correct |
74 |
Correct |
15 ms |
4932 KB |
Output is correct |
75 |
Correct |
32 ms |
5212 KB |
Output is correct |
76 |
Correct |
8 ms |
4188 KB |
Output is correct |
77 |
Correct |
83 ms |
5980 KB |
Output is correct |
78 |
Correct |
3 ms |
3416 KB |
Output is correct |
79 |
Correct |
39 ms |
4184 KB |
Output is correct |
80 |
Correct |
9 ms |
4188 KB |
Output is correct |
81 |
Correct |
92 ms |
5980 KB |
Output is correct |
82 |
Correct |
2 ms |
2904 KB |
Output is correct |
83 |
Correct |
41 ms |
4188 KB |
Output is correct |
84 |
Correct |
33 ms |
5212 KB |
Output is correct |
85 |
Correct |
2 ms |
2908 KB |
Output is correct |
86 |
Correct |
33 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2652 KB |
Output is correct |
3 |
Correct |
3 ms |
3420 KB |
Output is correct |
4 |
Correct |
3 ms |
3420 KB |
Output is correct |
5 |
Correct |
3 ms |
3424 KB |
Output is correct |
6 |
Correct |
3 ms |
3420 KB |
Output is correct |
7 |
Correct |
3 ms |
3332 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
0 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2908 KB |
Output is correct |
11 |
Correct |
4 ms |
3624 KB |
Output is correct |
12 |
Correct |
3 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
3420 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
5 ms |
3396 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
3 ms |
3420 KB |
Output is correct |
19 |
Correct |
1 ms |
2908 KB |
Output is correct |
20 |
Correct |
2 ms |
3272 KB |
Output is correct |
21 |
Correct |
2 ms |
3164 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
4 ms |
3676 KB |
Output is correct |
24 |
Correct |
1 ms |
2908 KB |
Output is correct |
25 |
Correct |
5 ms |
3676 KB |
Output is correct |
26 |
Correct |
4 ms |
3420 KB |
Output is correct |
27 |
Correct |
3 ms |
3420 KB |
Output is correct |
28 |
Correct |
3 ms |
3420 KB |
Output is correct |
29 |
Correct |
3 ms |
3420 KB |
Output is correct |
30 |
Correct |
4 ms |
3676 KB |
Output is correct |
31 |
Correct |
4 ms |
3676 KB |
Output is correct |
32 |
Correct |
6 ms |
3676 KB |
Output is correct |
33 |
Correct |
4 ms |
3676 KB |
Output is correct |
34 |
Correct |
4 ms |
3676 KB |
Output is correct |
35 |
Correct |
2 ms |
3164 KB |
Output is correct |
36 |
Correct |
2 ms |
3164 KB |
Output is correct |
37 |
Correct |
2 ms |
3164 KB |
Output is correct |
38 |
Correct |
2 ms |
2908 KB |
Output is correct |
39 |
Correct |
2 ms |
2908 KB |
Output is correct |
40 |
Correct |
6 ms |
3932 KB |
Output is correct |
41 |
Correct |
2 ms |
2908 KB |
Output is correct |
42 |
Correct |
7 ms |
3932 KB |
Output is correct |
43 |
Correct |
6 ms |
3928 KB |
Output is correct |
44 |
Correct |
1 ms |
2652 KB |
Output is correct |
45 |
Correct |
127 ms |
20852 KB |
Output is correct |
46 |
Correct |
63 ms |
12892 KB |
Output is correct |
47 |
Correct |
127 ms |
20816 KB |
Output is correct |
48 |
Correct |
130 ms |
20820 KB |
Output is correct |
49 |
Correct |
34 ms |
10324 KB |
Output is correct |
50 |
Correct |
140 ms |
26196 KB |
Output is correct |
51 |
Correct |
124 ms |
20816 KB |
Output is correct |
52 |
Correct |
31 ms |
10324 KB |
Output is correct |
53 |
Correct |
36 ms |
10328 KB |
Output is correct |
54 |
Correct |
8 ms |
5212 KB |
Output is correct |
55 |
Correct |
163 ms |
26108 KB |
Output is correct |
56 |
Correct |
18 ms |
7768 KB |
Output is correct |
57 |
Correct |
31 ms |
10328 KB |
Output is correct |
58 |
Correct |
40 ms |
13148 KB |
Output is correct |
59 |
Correct |
19 ms |
7772 KB |
Output is correct |
60 |
Correct |
19 ms |
7768 KB |
Output is correct |
61 |
Correct |
39 ms |
13148 KB |
Output is correct |
62 |
Correct |
27 ms |
10332 KB |
Output is correct |
63 |
Correct |
72 ms |
14424 KB |
Output is correct |
64 |
Correct |
21 ms |
7768 KB |
Output is correct |
65 |
Correct |
86 ms |
16932 KB |
Output is correct |
66 |
Correct |
27 ms |
10332 KB |
Output is correct |
67 |
Correct |
60 ms |
14424 KB |
Output is correct |
68 |
Correct |
77 ms |
16216 KB |
Output is correct |
69 |
Correct |
85 ms |
16984 KB |
Output is correct |
70 |
Correct |
29 ms |
10332 KB |
Output is correct |
71 |
Correct |
90 ms |
16216 KB |
Output is correct |
72 |
Correct |
66 ms |
14012 KB |
Output is correct |
73 |
Correct |
99 ms |
18524 KB |
Output is correct |
74 |
Correct |
29 ms |
10328 KB |
Output is correct |
75 |
Correct |
31 ms |
9048 KB |
Output is correct |
76 |
Correct |
68 ms |
13908 KB |
Output is correct |
77 |
Correct |
93 ms |
18800 KB |
Output is correct |
78 |
Correct |
45 ms |
10584 KB |
Output is correct |
79 |
Correct |
35 ms |
9052 KB |
Output is correct |
80 |
Correct |
15 ms |
5724 KB |
Output is correct |
81 |
Correct |
47 ms |
10544 KB |
Output is correct |
82 |
Correct |
73 ms |
15704 KB |
Output is correct |
83 |
Correct |
15 ms |
5724 KB |
Output is correct |
84 |
Correct |
75 ms |
15712 KB |
Output is correct |