#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int MAXB = 10;
int n, kk;
set <int> M[MAXN];
int minbit[1 << MAXB], f[MAXB], cnt[1 << MAXB];
bitset <1 << MAXB> B;
bool Vis[MAXN];
int Check(int i)
{
int ans = 1;
int sz = M[i].size();
vector <int> Adj;
for(auto x : M[i])
{
Adj.push_back(x);
}
for(int j = 0; j < sz; j++)
{
f[j] = 0;
}
for(int j = 0; j < sz; j++)
{
for(int k = j + 1; k < sz; k++)
{
if(M[Adj[j]].count(Adj[k]))
{
f[j] |= (1 << k);
f[k] |= (1 << j);
}
}
f[j] |= (1 << j);
}
B.reset();
B[0] = 1;
for(int j = 1; j < (1 << sz); j++)
{
if((f[minbit[j]] & j) == j and B[j ^ (1 << minbit[j])])
{
B[j] = true;
ans = max(ans, cnt[j] + 1);
}
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
for(int i = 1; i < 1 << MAXB; i++)
{
for(int j = 0; j < MAXB; j++)
{
if(i & (1 << j))
{
minbit[i] = j;
cnt[i] = cnt[i ^ (1 << j)] + 1;
break;
}
}
}
cin >> n >> kk;
for(int i = 0; i < n; i++)
{
int sz;
cin >> sz;
for(int j = 0; j < sz; j++)
{
int a;
cin >> a;
M[i].emplace(a);
}
}
int ans = 1;
queue <int> Q;
for(int i = 0; i < n; i++)
{
if((int)M[i].size() < kk)
{
Q.push(i);
Vis[i] = true;
}
}
while(Q.empty() == false)
{
int node = Q.front();
ans = max(ans, Check(node));
Q.pop();
for(auto x : M[node])
{
M[x].erase(node);
if((int)M[x].size() < kk and !Vis[x])
{
Q.push(x);
Vis[x] = true;
}
}
M[node].clear();
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5028 KB |
Output is correct |
3 |
Correct |
6 ms |
5560 KB |
Output is correct |
4 |
Correct |
5 ms |
5580 KB |
Output is correct |
5 |
Correct |
5 ms |
5528 KB |
Output is correct |
6 |
Correct |
5 ms |
5580 KB |
Output is correct |
7 |
Correct |
7 ms |
5452 KB |
Output is correct |
8 |
Correct |
3 ms |
4976 KB |
Output is correct |
9 |
Correct |
3 ms |
4940 KB |
Output is correct |
10 |
Correct |
4 ms |
5068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5028 KB |
Output is correct |
3 |
Correct |
6 ms |
5560 KB |
Output is correct |
4 |
Correct |
5 ms |
5580 KB |
Output is correct |
5 |
Correct |
5 ms |
5528 KB |
Output is correct |
6 |
Correct |
5 ms |
5580 KB |
Output is correct |
7 |
Correct |
7 ms |
5452 KB |
Output is correct |
8 |
Correct |
3 ms |
4976 KB |
Output is correct |
9 |
Correct |
3 ms |
4940 KB |
Output is correct |
10 |
Correct |
4 ms |
5068 KB |
Output is correct |
11 |
Correct |
5 ms |
5580 KB |
Output is correct |
12 |
Correct |
6 ms |
5580 KB |
Output is correct |
13 |
Correct |
2 ms |
4940 KB |
Output is correct |
14 |
Correct |
5 ms |
5580 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
5 ms |
5580 KB |
Output is correct |
17 |
Correct |
3 ms |
4940 KB |
Output is correct |
18 |
Correct |
5 ms |
5452 KB |
Output is correct |
19 |
Correct |
4 ms |
4940 KB |
Output is correct |
20 |
Correct |
3 ms |
5248 KB |
Output is correct |
21 |
Correct |
6 ms |
5296 KB |
Output is correct |
22 |
Correct |
3 ms |
5068 KB |
Output is correct |
23 |
Correct |
9 ms |
5580 KB |
Output is correct |
24 |
Correct |
3 ms |
4940 KB |
Output is correct |
25 |
Correct |
7 ms |
5580 KB |
Output is correct |
26 |
Correct |
5 ms |
5608 KB |
Output is correct |
27 |
Correct |
5 ms |
5548 KB |
Output is correct |
28 |
Correct |
5 ms |
5544 KB |
Output is correct |
29 |
Correct |
5 ms |
5580 KB |
Output is correct |
30 |
Correct |
8 ms |
5708 KB |
Output is correct |
31 |
Correct |
5 ms |
5708 KB |
Output is correct |
32 |
Correct |
6 ms |
5744 KB |
Output is correct |
33 |
Correct |
6 ms |
5708 KB |
Output is correct |
34 |
Correct |
6 ms |
5708 KB |
Output is correct |
35 |
Correct |
4 ms |
5324 KB |
Output is correct |
36 |
Correct |
5 ms |
5372 KB |
Output is correct |
37 |
Correct |
7 ms |
5376 KB |
Output is correct |
38 |
Correct |
4 ms |
5196 KB |
Output is correct |
39 |
Correct |
4 ms |
5172 KB |
Output is correct |
40 |
Correct |
8 ms |
6064 KB |
Output is correct |
41 |
Correct |
4 ms |
5196 KB |
Output is correct |
42 |
Correct |
7 ms |
5964 KB |
Output is correct |
43 |
Correct |
8 ms |
6076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
2 ms |
4940 KB |
Output is correct |
4 |
Correct |
2 ms |
4940 KB |
Output is correct |
5 |
Correct |
3 ms |
4940 KB |
Output is correct |
6 |
Correct |
3 ms |
4940 KB |
Output is correct |
7 |
Correct |
3 ms |
4940 KB |
Output is correct |
8 |
Correct |
2 ms |
4940 KB |
Output is correct |
9 |
Correct |
2 ms |
5028 KB |
Output is correct |
10 |
Correct |
2 ms |
5028 KB |
Output is correct |
11 |
Correct |
171 ms |
28972 KB |
Output is correct |
12 |
Correct |
2 ms |
4940 KB |
Output is correct |
13 |
Correct |
186 ms |
28968 KB |
Output is correct |
14 |
Correct |
3 ms |
4940 KB |
Output is correct |
15 |
Correct |
182 ms |
29060 KB |
Output is correct |
16 |
Correct |
172 ms |
29048 KB |
Output is correct |
17 |
Correct |
174 ms |
28932 KB |
Output is correct |
18 |
Correct |
194 ms |
29040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5028 KB |
Output is correct |
3 |
Correct |
6 ms |
5560 KB |
Output is correct |
4 |
Correct |
5 ms |
5580 KB |
Output is correct |
5 |
Correct |
5 ms |
5528 KB |
Output is correct |
6 |
Correct |
5 ms |
5580 KB |
Output is correct |
7 |
Correct |
7 ms |
5452 KB |
Output is correct |
8 |
Correct |
3 ms |
4976 KB |
Output is correct |
9 |
Correct |
3 ms |
4940 KB |
Output is correct |
10 |
Correct |
4 ms |
5068 KB |
Output is correct |
11 |
Correct |
5 ms |
5580 KB |
Output is correct |
12 |
Correct |
6 ms |
5580 KB |
Output is correct |
13 |
Correct |
2 ms |
4940 KB |
Output is correct |
14 |
Correct |
5 ms |
5580 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
5 ms |
5580 KB |
Output is correct |
17 |
Correct |
3 ms |
4940 KB |
Output is correct |
18 |
Correct |
5 ms |
5452 KB |
Output is correct |
19 |
Correct |
4 ms |
4940 KB |
Output is correct |
20 |
Correct |
3 ms |
5248 KB |
Output is correct |
21 |
Correct |
6 ms |
5296 KB |
Output is correct |
22 |
Correct |
3 ms |
5068 KB |
Output is correct |
23 |
Correct |
9 ms |
5580 KB |
Output is correct |
24 |
Correct |
3 ms |
4940 KB |
Output is correct |
25 |
Correct |
7 ms |
5580 KB |
Output is correct |
26 |
Correct |
5 ms |
5608 KB |
Output is correct |
27 |
Correct |
5 ms |
5548 KB |
Output is correct |
28 |
Correct |
5 ms |
5544 KB |
Output is correct |
29 |
Correct |
5 ms |
5580 KB |
Output is correct |
30 |
Correct |
8 ms |
5708 KB |
Output is correct |
31 |
Correct |
5 ms |
5708 KB |
Output is correct |
32 |
Correct |
6 ms |
5744 KB |
Output is correct |
33 |
Correct |
6 ms |
5708 KB |
Output is correct |
34 |
Correct |
6 ms |
5708 KB |
Output is correct |
35 |
Correct |
4 ms |
5324 KB |
Output is correct |
36 |
Correct |
5 ms |
5372 KB |
Output is correct |
37 |
Correct |
7 ms |
5376 KB |
Output is correct |
38 |
Correct |
4 ms |
5196 KB |
Output is correct |
39 |
Correct |
4 ms |
5172 KB |
Output is correct |
40 |
Correct |
8 ms |
6064 KB |
Output is correct |
41 |
Correct |
4 ms |
5196 KB |
Output is correct |
42 |
Correct |
7 ms |
5964 KB |
Output is correct |
43 |
Correct |
8 ms |
6076 KB |
Output is correct |
44 |
Correct |
13 ms |
7116 KB |
Output is correct |
45 |
Correct |
2 ms |
5024 KB |
Output is correct |
46 |
Correct |
7 ms |
6064 KB |
Output is correct |
47 |
Correct |
13 ms |
7028 KB |
Output is correct |
48 |
Correct |
8 ms |
6064 KB |
Output is correct |
49 |
Correct |
14 ms |
7116 KB |
Output is correct |
50 |
Correct |
15 ms |
6984 KB |
Output is correct |
51 |
Correct |
28 ms |
9148 KB |
Output is correct |
52 |
Correct |
6 ms |
5452 KB |
Output is correct |
53 |
Correct |
32 ms |
9684 KB |
Output is correct |
54 |
Correct |
31 ms |
9580 KB |
Output is correct |
55 |
Correct |
5 ms |
5580 KB |
Output is correct |
56 |
Correct |
5 ms |
5580 KB |
Output is correct |
57 |
Correct |
3 ms |
5068 KB |
Output is correct |
58 |
Correct |
39 ms |
9696 KB |
Output is correct |
59 |
Correct |
7 ms |
6092 KB |
Output is correct |
60 |
Correct |
7 ms |
5452 KB |
Output is correct |
61 |
Correct |
7 ms |
6060 KB |
Output is correct |
62 |
Correct |
9 ms |
6096 KB |
Output is correct |
63 |
Correct |
14 ms |
7128 KB |
Output is correct |
64 |
Correct |
12 ms |
6860 KB |
Output is correct |
65 |
Correct |
7 ms |
5836 KB |
Output is correct |
66 |
Correct |
7 ms |
6092 KB |
Output is correct |
67 |
Correct |
16 ms |
7516 KB |
Output is correct |
68 |
Correct |
11 ms |
6828 KB |
Output is correct |
69 |
Correct |
7 ms |
5836 KB |
Output is correct |
70 |
Correct |
13 ms |
6900 KB |
Output is correct |
71 |
Correct |
16 ms |
7440 KB |
Output is correct |
72 |
Correct |
15 ms |
7428 KB |
Output is correct |
73 |
Correct |
5 ms |
5580 KB |
Output is correct |
74 |
Correct |
15 ms |
6860 KB |
Output is correct |
75 |
Correct |
16 ms |
7372 KB |
Output is correct |
76 |
Correct |
10 ms |
6348 KB |
Output is correct |
77 |
Correct |
21 ms |
8012 KB |
Output is correct |
78 |
Correct |
7 ms |
5580 KB |
Output is correct |
79 |
Correct |
16 ms |
6508 KB |
Output is correct |
80 |
Correct |
14 ms |
6348 KB |
Output is correct |
81 |
Correct |
21 ms |
8004 KB |
Output is correct |
82 |
Correct |
5 ms |
5164 KB |
Output is correct |
83 |
Correct |
12 ms |
6476 KB |
Output is correct |
84 |
Correct |
13 ms |
7384 KB |
Output is correct |
85 |
Correct |
3 ms |
5196 KB |
Output is correct |
86 |
Correct |
15 ms |
7384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5028 KB |
Output is correct |
3 |
Correct |
6 ms |
5560 KB |
Output is correct |
4 |
Correct |
5 ms |
5580 KB |
Output is correct |
5 |
Correct |
5 ms |
5528 KB |
Output is correct |
6 |
Correct |
5 ms |
5580 KB |
Output is correct |
7 |
Correct |
7 ms |
5452 KB |
Output is correct |
8 |
Correct |
3 ms |
4976 KB |
Output is correct |
9 |
Correct |
3 ms |
4940 KB |
Output is correct |
10 |
Correct |
4 ms |
5068 KB |
Output is correct |
11 |
Correct |
5 ms |
5580 KB |
Output is correct |
12 |
Correct |
6 ms |
5580 KB |
Output is correct |
13 |
Correct |
2 ms |
4940 KB |
Output is correct |
14 |
Correct |
5 ms |
5580 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
5 ms |
5580 KB |
Output is correct |
17 |
Correct |
3 ms |
4940 KB |
Output is correct |
18 |
Correct |
5 ms |
5452 KB |
Output is correct |
19 |
Correct |
4 ms |
4940 KB |
Output is correct |
20 |
Correct |
3 ms |
5248 KB |
Output is correct |
21 |
Correct |
6 ms |
5296 KB |
Output is correct |
22 |
Correct |
3 ms |
5068 KB |
Output is correct |
23 |
Correct |
9 ms |
5580 KB |
Output is correct |
24 |
Correct |
3 ms |
4940 KB |
Output is correct |
25 |
Correct |
7 ms |
5580 KB |
Output is correct |
26 |
Correct |
5 ms |
5608 KB |
Output is correct |
27 |
Correct |
5 ms |
5548 KB |
Output is correct |
28 |
Correct |
5 ms |
5544 KB |
Output is correct |
29 |
Correct |
5 ms |
5580 KB |
Output is correct |
30 |
Correct |
8 ms |
5708 KB |
Output is correct |
31 |
Correct |
5 ms |
5708 KB |
Output is correct |
32 |
Correct |
6 ms |
5744 KB |
Output is correct |
33 |
Correct |
6 ms |
5708 KB |
Output is correct |
34 |
Correct |
6 ms |
5708 KB |
Output is correct |
35 |
Correct |
4 ms |
5324 KB |
Output is correct |
36 |
Correct |
5 ms |
5372 KB |
Output is correct |
37 |
Correct |
7 ms |
5376 KB |
Output is correct |
38 |
Correct |
4 ms |
5196 KB |
Output is correct |
39 |
Correct |
4 ms |
5172 KB |
Output is correct |
40 |
Correct |
8 ms |
6064 KB |
Output is correct |
41 |
Correct |
4 ms |
5196 KB |
Output is correct |
42 |
Correct |
7 ms |
5964 KB |
Output is correct |
43 |
Correct |
8 ms |
6076 KB |
Output is correct |
44 |
Correct |
2 ms |
4940 KB |
Output is correct |
45 |
Correct |
116 ms |
21020 KB |
Output is correct |
46 |
Correct |
59 ms |
13124 KB |
Output is correct |
47 |
Correct |
141 ms |
20968 KB |
Output is correct |
48 |
Correct |
115 ms |
20984 KB |
Output is correct |
49 |
Correct |
34 ms |
10564 KB |
Output is correct |
50 |
Correct |
136 ms |
26404 KB |
Output is correct |
51 |
Correct |
127 ms |
21104 KB |
Output is correct |
52 |
Correct |
35 ms |
10552 KB |
Output is correct |
53 |
Correct |
45 ms |
10532 KB |
Output is correct |
54 |
Correct |
6 ms |
5324 KB |
Output is correct |
55 |
Correct |
138 ms |
26308 KB |
Output is correct |
56 |
Correct |
15 ms |
8012 KB |
Output is correct |
57 |
Correct |
33 ms |
10572 KB |
Output is correct |
58 |
Correct |
42 ms |
13164 KB |
Output is correct |
59 |
Correct |
16 ms |
8024 KB |
Output is correct |
60 |
Correct |
20 ms |
7964 KB |
Output is correct |
61 |
Correct |
41 ms |
13252 KB |
Output is correct |
62 |
Correct |
31 ms |
10572 KB |
Output is correct |
63 |
Correct |
70 ms |
14400 KB |
Output is correct |
64 |
Correct |
18 ms |
7952 KB |
Output is correct |
65 |
Correct |
86 ms |
17040 KB |
Output is correct |
66 |
Correct |
28 ms |
10572 KB |
Output is correct |
67 |
Correct |
65 ms |
14480 KB |
Output is correct |
68 |
Correct |
87 ms |
16368 KB |
Output is correct |
69 |
Correct |
95 ms |
17000 KB |
Output is correct |
70 |
Correct |
30 ms |
10620 KB |
Output is correct |
71 |
Correct |
78 ms |
16452 KB |
Output is correct |
72 |
Correct |
64 ms |
14008 KB |
Output is correct |
73 |
Correct |
128 ms |
18780 KB |
Output is correct |
74 |
Correct |
30 ms |
10588 KB |
Output is correct |
75 |
Correct |
31 ms |
10184 KB |
Output is correct |
76 |
Correct |
60 ms |
14120 KB |
Output is correct |
77 |
Correct |
104 ms |
18760 KB |
Output is correct |
78 |
Correct |
42 ms |
11804 KB |
Output is correct |
79 |
Correct |
30 ms |
10188 KB |
Output is correct |
80 |
Correct |
15 ms |
7676 KB |
Output is correct |
81 |
Correct |
43 ms |
11764 KB |
Output is correct |
82 |
Correct |
64 ms |
15852 KB |
Output is correct |
83 |
Correct |
18 ms |
7628 KB |
Output is correct |
84 |
Correct |
73 ms |
15860 KB |
Output is correct |