#include <bits/stdc++.h>
using namespace std;
void solve(){
int n, k; cin >> n >> k;
vector<vector<int>> adj(n);
set<pair<int,int>> uwu;
vector<int> cnt(n);
vector<int> vis(n, 0);
for(int i = 0; i < n; i++){
cin >> cnt[i]; uwu.insert({cnt[i], i});
adj[i] = vector<int>(cnt[i]);
for(auto &x : adj[i]) cin >> x;
sort(adj[i].begin(), adj[i].end()); //yeee
}
int ans = 1;
while(uwu.size()){
int i = uwu.begin()->second; vis[i] = 1;
uwu.erase(uwu.begin());
vector<int> clique = {i};
for(auto &x : adj[i]){
if(vis[x]) continue;
clique.push_back(x);
uwu.erase({cnt[x], x});
cnt[x]--;
uwu.insert({cnt[x], x});
}
int sz = clique.size();
vector<vector<int>> adj2(sz, vector<int>(sz, 0));
for(int i = 0; i < sz; i++){
for(int j = 0; j < sz; j++){
int i2 = clique[i];
int j2 = clique[j];
auto it = lower_bound(adj[i2].begin(), adj[i2].end(), j2);
if(it != adj[i2].end() && (*it) == j2) adj2[i][j] = 1;
}
}
vector<int> possible((1<<sz), 0);
vector<int> log2((1<<sz), 0);
for(int i = 0; i < sz; i++) log2[(1<<i)] = i;
for(int i = 0; i < (1<<sz); i++){
if(i==0){possible[i] = 1; continue;}
int lsb = (i&-i);
int j = i^lsb;
possible[i] = possible[j];
while(j){
int lsb2 = (j&-j);
possible[i] &= adj2[log2[lsb]][log2[lsb2]];
j ^= lsb2;
}
if(possible[i]) ans = max(ans, (int)__builtin_popcount(i));
}
}
cout<<ans<<endl;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;// cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
1080 KB |
Output is correct |
5 |
Correct |
4 ms |
860 KB |
Output is correct |
6 |
Correct |
4 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
856 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
1080 KB |
Output is correct |
5 |
Correct |
4 ms |
860 KB |
Output is correct |
6 |
Correct |
4 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
856 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
4 ms |
860 KB |
Output is correct |
12 |
Correct |
4 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
352 KB |
Output is correct |
14 |
Correct |
4 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
864 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
980 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
3 ms |
1036 KB |
Output is correct |
22 |
Correct |
2 ms |
864 KB |
Output is correct |
23 |
Correct |
6 ms |
984 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
5 ms |
1076 KB |
Output is correct |
26 |
Correct |
5 ms |
860 KB |
Output is correct |
27 |
Correct |
5 ms |
864 KB |
Output is correct |
28 |
Correct |
5 ms |
1112 KB |
Output is correct |
29 |
Correct |
4 ms |
860 KB |
Output is correct |
30 |
Correct |
5 ms |
860 KB |
Output is correct |
31 |
Correct |
5 ms |
860 KB |
Output is correct |
32 |
Correct |
6 ms |
856 KB |
Output is correct |
33 |
Correct |
5 ms |
860 KB |
Output is correct |
34 |
Correct |
5 ms |
860 KB |
Output is correct |
35 |
Correct |
3 ms |
604 KB |
Output is correct |
36 |
Correct |
3 ms |
608 KB |
Output is correct |
37 |
Correct |
3 ms |
608 KB |
Output is correct |
38 |
Correct |
2 ms |
604 KB |
Output is correct |
39 |
Correct |
2 ms |
608 KB |
Output is correct |
40 |
Correct |
7 ms |
1116 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
8 ms |
1116 KB |
Output is correct |
43 |
Correct |
7 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
456 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
224 ms |
9356 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
218 ms |
9468 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
202 ms |
9356 KB |
Output is correct |
16 |
Correct |
202 ms |
9356 KB |
Output is correct |
17 |
Correct |
204 ms |
9400 KB |
Output is correct |
18 |
Correct |
208 ms |
9200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
1080 KB |
Output is correct |
5 |
Correct |
4 ms |
860 KB |
Output is correct |
6 |
Correct |
4 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
856 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
4 ms |
860 KB |
Output is correct |
12 |
Correct |
4 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
352 KB |
Output is correct |
14 |
Correct |
4 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
864 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
980 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
3 ms |
1036 KB |
Output is correct |
22 |
Correct |
2 ms |
864 KB |
Output is correct |
23 |
Correct |
6 ms |
984 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
5 ms |
1076 KB |
Output is correct |
26 |
Correct |
5 ms |
860 KB |
Output is correct |
27 |
Correct |
5 ms |
864 KB |
Output is correct |
28 |
Correct |
5 ms |
1112 KB |
Output is correct |
29 |
Correct |
4 ms |
860 KB |
Output is correct |
30 |
Correct |
5 ms |
860 KB |
Output is correct |
31 |
Correct |
5 ms |
860 KB |
Output is correct |
32 |
Correct |
6 ms |
856 KB |
Output is correct |
33 |
Correct |
5 ms |
860 KB |
Output is correct |
34 |
Correct |
5 ms |
860 KB |
Output is correct |
35 |
Correct |
3 ms |
604 KB |
Output is correct |
36 |
Correct |
3 ms |
608 KB |
Output is correct |
37 |
Correct |
3 ms |
608 KB |
Output is correct |
38 |
Correct |
2 ms |
604 KB |
Output is correct |
39 |
Correct |
2 ms |
608 KB |
Output is correct |
40 |
Correct |
7 ms |
1116 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
8 ms |
1116 KB |
Output is correct |
43 |
Correct |
7 ms |
1116 KB |
Output is correct |
44 |
Correct |
13 ms |
1116 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
9 ms |
1116 KB |
Output is correct |
47 |
Correct |
14 ms |
1112 KB |
Output is correct |
48 |
Correct |
10 ms |
1116 KB |
Output is correct |
49 |
Correct |
14 ms |
1116 KB |
Output is correct |
50 |
Correct |
15 ms |
1276 KB |
Output is correct |
51 |
Correct |
45 ms |
1624 KB |
Output is correct |
52 |
Correct |
4 ms |
856 KB |
Output is correct |
53 |
Correct |
54 ms |
1672 KB |
Output is correct |
54 |
Correct |
66 ms |
1628 KB |
Output is correct |
55 |
Correct |
5 ms |
856 KB |
Output is correct |
56 |
Correct |
4 ms |
860 KB |
Output is correct |
57 |
Correct |
2 ms |
860 KB |
Output is correct |
58 |
Correct |
53 ms |
1604 KB |
Output is correct |
59 |
Correct |
5 ms |
856 KB |
Output is correct |
60 |
Correct |
4 ms |
860 KB |
Output is correct |
61 |
Correct |
7 ms |
860 KB |
Output is correct |
62 |
Correct |
5 ms |
1104 KB |
Output is correct |
63 |
Correct |
12 ms |
1120 KB |
Output is correct |
64 |
Correct |
10 ms |
1116 KB |
Output is correct |
65 |
Correct |
7 ms |
976 KB |
Output is correct |
66 |
Correct |
6 ms |
964 KB |
Output is correct |
67 |
Correct |
19 ms |
1368 KB |
Output is correct |
68 |
Correct |
11 ms |
1116 KB |
Output is correct |
69 |
Correct |
7 ms |
860 KB |
Output is correct |
70 |
Correct |
13 ms |
1052 KB |
Output is correct |
71 |
Correct |
19 ms |
1116 KB |
Output is correct |
72 |
Correct |
18 ms |
1116 KB |
Output is correct |
73 |
Correct |
4 ms |
860 KB |
Output is correct |
74 |
Correct |
13 ms |
1116 KB |
Output is correct |
75 |
Correct |
18 ms |
1116 KB |
Output is correct |
76 |
Correct |
9 ms |
1156 KB |
Output is correct |
77 |
Correct |
25 ms |
1372 KB |
Output is correct |
78 |
Correct |
4 ms |
860 KB |
Output is correct |
79 |
Correct |
12 ms |
860 KB |
Output is correct |
80 |
Correct |
9 ms |
1116 KB |
Output is correct |
81 |
Correct |
25 ms |
1372 KB |
Output is correct |
82 |
Correct |
2 ms |
604 KB |
Output is correct |
83 |
Correct |
12 ms |
860 KB |
Output is correct |
84 |
Correct |
16 ms |
1116 KB |
Output is correct |
85 |
Correct |
2 ms |
856 KB |
Output is correct |
86 |
Correct |
17 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
1080 KB |
Output is correct |
5 |
Correct |
4 ms |
860 KB |
Output is correct |
6 |
Correct |
4 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
856 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
4 ms |
860 KB |
Output is correct |
12 |
Correct |
4 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
352 KB |
Output is correct |
14 |
Correct |
4 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
864 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
980 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
3 ms |
1036 KB |
Output is correct |
22 |
Correct |
2 ms |
864 KB |
Output is correct |
23 |
Correct |
6 ms |
984 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
5 ms |
1076 KB |
Output is correct |
26 |
Correct |
5 ms |
860 KB |
Output is correct |
27 |
Correct |
5 ms |
864 KB |
Output is correct |
28 |
Correct |
5 ms |
1112 KB |
Output is correct |
29 |
Correct |
4 ms |
860 KB |
Output is correct |
30 |
Correct |
5 ms |
860 KB |
Output is correct |
31 |
Correct |
5 ms |
860 KB |
Output is correct |
32 |
Correct |
6 ms |
856 KB |
Output is correct |
33 |
Correct |
5 ms |
860 KB |
Output is correct |
34 |
Correct |
5 ms |
860 KB |
Output is correct |
35 |
Correct |
3 ms |
604 KB |
Output is correct |
36 |
Correct |
3 ms |
608 KB |
Output is correct |
37 |
Correct |
3 ms |
608 KB |
Output is correct |
38 |
Correct |
2 ms |
604 KB |
Output is correct |
39 |
Correct |
2 ms |
608 KB |
Output is correct |
40 |
Correct |
7 ms |
1116 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
8 ms |
1116 KB |
Output is correct |
43 |
Correct |
7 ms |
1116 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
133 ms |
8100 KB |
Output is correct |
46 |
Correct |
69 ms |
6996 KB |
Output is correct |
47 |
Correct |
129 ms |
8100 KB |
Output is correct |
48 |
Correct |
128 ms |
8088 KB |
Output is correct |
49 |
Correct |
39 ms |
6740 KB |
Output is correct |
50 |
Correct |
114 ms |
8972 KB |
Output is correct |
51 |
Correct |
129 ms |
8028 KB |
Output is correct |
52 |
Correct |
50 ms |
6744 KB |
Output is correct |
53 |
Correct |
40 ms |
6736 KB |
Output is correct |
54 |
Correct |
16 ms |
4444 KB |
Output is correct |
55 |
Correct |
120 ms |
9056 KB |
Output is correct |
56 |
Correct |
33 ms |
6484 KB |
Output is correct |
57 |
Correct |
43 ms |
6744 KB |
Output is correct |
58 |
Correct |
46 ms |
6740 KB |
Output is correct |
59 |
Correct |
28 ms |
6236 KB |
Output is correct |
60 |
Correct |
28 ms |
6336 KB |
Output is correct |
61 |
Correct |
46 ms |
6748 KB |
Output is correct |
62 |
Correct |
42 ms |
6408 KB |
Output is correct |
63 |
Correct |
81 ms |
7056 KB |
Output is correct |
64 |
Correct |
29 ms |
6168 KB |
Output is correct |
65 |
Correct |
107 ms |
7288 KB |
Output is correct |
66 |
Correct |
36 ms |
6492 KB |
Output is correct |
67 |
Correct |
76 ms |
7068 KB |
Output is correct |
68 |
Correct |
102 ms |
7508 KB |
Output is correct |
69 |
Correct |
95 ms |
7444 KB |
Output is correct |
70 |
Correct |
41 ms |
6592 KB |
Output is correct |
71 |
Correct |
91 ms |
7248 KB |
Output is correct |
72 |
Correct |
69 ms |
7108 KB |
Output is correct |
73 |
Correct |
118 ms |
7516 KB |
Output is correct |
74 |
Correct |
40 ms |
6480 KB |
Output is correct |
75 |
Correct |
38 ms |
3676 KB |
Output is correct |
76 |
Correct |
70 ms |
6904 KB |
Output is correct |
77 |
Correct |
107 ms |
7592 KB |
Output is correct |
78 |
Correct |
50 ms |
3928 KB |
Output is correct |
79 |
Correct |
40 ms |
3644 KB |
Output is correct |
80 |
Correct |
19 ms |
2136 KB |
Output is correct |
81 |
Correct |
50 ms |
3932 KB |
Output is correct |
82 |
Correct |
81 ms |
7156 KB |
Output is correct |
83 |
Correct |
19 ms |
2196 KB |
Output is correct |
84 |
Correct |
84 ms |
7120 KB |
Output is correct |