#include <bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
using namespace std;
// using namespace __gnu_pbds;
using namespace chrono;
// mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
/*
template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
//***************** CONSTANTS *****************
const int MXN = 50000;
//***************** GLOBAL VARIABLES *****************
set<int> g[MXN];
int D[MXN];
//***************** AUXILIARY STRUCTS *****************
//***************** MAIN BODY *****************
void solve(){
int N, K;
cin >> N >> K;
priority_queue<array<int, 2>> pq;
for(int i = 0; i < N; i++){
cin >> D[i];
for(int _ = 0; _ < D[i]; _++){
int x;
cin >> x;
g[i].insert(x);
}
pq.push({-D[i], i});
}
int ans = 1;
while(!pq.empty()){
auto [deg, u] = pq.top();
pq.pop();
deg *= -1;
if(deg != D[u])
continue;
vector<int> t(D[u]);
int ptr = 0;
for(int v : g[u]) t[ptr++] = v;
for(int mask = 1; mask < (1 << deg); mask++){
vector<int> vec;
for(int i = 0; i < deg; i++)
if((mask >> i) & 1)
vec.push_back(t[i]);
int k = vec.size();
bool ok = true;
for(int i = 0; i < k && ok; i++)
for(int j = i + 1; j < k && ok; j++)
if(g[vec[i]].find(vec[j]) == g[vec[i]].end()){
ok = false;
break;
}
if(ok) ans = max(ans, k + 1);
}
for(int v : g[u]){
g[v].erase(u);
D[v]--;
pq.push({-D[v], v});
}
}
cout << ans << '\n';
}
//***************** *****************
int32_t main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
#ifdef LOCAL
auto begin = high_resolution_clock::now();
#endif
int tc = 1;
// cin >> tc;
for (int t = 0; t < tc; t++)
solve();
#ifdef LOCAL
auto end = high_resolution_clock::now();
cout << fixed << setprecision(4);
cout << "Execution Time: " << duration_cast<duration<double>>(end - begin).count() << "seconds" << endl;
#endif
return 0;
}
/*
If code gives a WA, check for the following :
1. I/O format
2. Are you clearing all global variables in between tests if multitests are a thing
3. Can you definitively prove the logic
4. If the code gives an inexplicable TLE, and you are sure you have the best possible complexity,
use faster io
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3148 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3148 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
11 |
Correct |
6 ms |
3148 KB |
Output is correct |
12 |
Correct |
7 ms |
3260 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
6 ms |
3188 KB |
Output is correct |
15 |
Correct |
2 ms |
2636 KB |
Output is correct |
16 |
Correct |
6 ms |
3260 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
7 ms |
3264 KB |
Output is correct |
19 |
Correct |
3 ms |
2764 KB |
Output is correct |
20 |
Correct |
4 ms |
2932 KB |
Output is correct |
21 |
Correct |
4 ms |
2892 KB |
Output is correct |
22 |
Correct |
2 ms |
2764 KB |
Output is correct |
23 |
Correct |
8 ms |
3320 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
8 ms |
3276 KB |
Output is correct |
26 |
Correct |
7 ms |
3228 KB |
Output is correct |
27 |
Correct |
5 ms |
3148 KB |
Output is correct |
28 |
Correct |
7 ms |
3276 KB |
Output is correct |
29 |
Correct |
6 ms |
3148 KB |
Output is correct |
30 |
Correct |
8 ms |
3320 KB |
Output is correct |
31 |
Correct |
7 ms |
3328 KB |
Output is correct |
32 |
Correct |
8 ms |
3436 KB |
Output is correct |
33 |
Correct |
10 ms |
3404 KB |
Output is correct |
34 |
Correct |
9 ms |
3412 KB |
Output is correct |
35 |
Correct |
5 ms |
2940 KB |
Output is correct |
36 |
Correct |
5 ms |
2932 KB |
Output is correct |
37 |
Correct |
5 ms |
3020 KB |
Output is correct |
38 |
Correct |
4 ms |
2892 KB |
Output is correct |
39 |
Correct |
5 ms |
2892 KB |
Output is correct |
40 |
Correct |
11 ms |
3792 KB |
Output is correct |
41 |
Correct |
4 ms |
2892 KB |
Output is correct |
42 |
Correct |
11 ms |
3832 KB |
Output is correct |
43 |
Correct |
10 ms |
3832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2764 KB |
Output is correct |
2 |
Correct |
2 ms |
2664 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2636 KB |
Output is correct |
5 |
Correct |
2 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
2 ms |
2760 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
495 ms |
28600 KB |
Output is correct |
12 |
Correct |
2 ms |
2636 KB |
Output is correct |
13 |
Correct |
491 ms |
28636 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
503 ms |
28656 KB |
Output is correct |
16 |
Correct |
508 ms |
28896 KB |
Output is correct |
17 |
Correct |
478 ms |
28584 KB |
Output is correct |
18 |
Correct |
561 ms |
28568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3148 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
11 |
Correct |
6 ms |
3148 KB |
Output is correct |
12 |
Correct |
7 ms |
3260 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
6 ms |
3188 KB |
Output is correct |
15 |
Correct |
2 ms |
2636 KB |
Output is correct |
16 |
Correct |
6 ms |
3260 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
7 ms |
3264 KB |
Output is correct |
19 |
Correct |
3 ms |
2764 KB |
Output is correct |
20 |
Correct |
4 ms |
2932 KB |
Output is correct |
21 |
Correct |
4 ms |
2892 KB |
Output is correct |
22 |
Correct |
2 ms |
2764 KB |
Output is correct |
23 |
Correct |
8 ms |
3320 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
8 ms |
3276 KB |
Output is correct |
26 |
Correct |
7 ms |
3228 KB |
Output is correct |
27 |
Correct |
5 ms |
3148 KB |
Output is correct |
28 |
Correct |
7 ms |
3276 KB |
Output is correct |
29 |
Correct |
6 ms |
3148 KB |
Output is correct |
30 |
Correct |
8 ms |
3320 KB |
Output is correct |
31 |
Correct |
7 ms |
3328 KB |
Output is correct |
32 |
Correct |
8 ms |
3436 KB |
Output is correct |
33 |
Correct |
10 ms |
3404 KB |
Output is correct |
34 |
Correct |
9 ms |
3412 KB |
Output is correct |
35 |
Correct |
5 ms |
2940 KB |
Output is correct |
36 |
Correct |
5 ms |
2932 KB |
Output is correct |
37 |
Correct |
5 ms |
3020 KB |
Output is correct |
38 |
Correct |
4 ms |
2892 KB |
Output is correct |
39 |
Correct |
5 ms |
2892 KB |
Output is correct |
40 |
Correct |
11 ms |
3792 KB |
Output is correct |
41 |
Correct |
4 ms |
2892 KB |
Output is correct |
42 |
Correct |
11 ms |
3832 KB |
Output is correct |
43 |
Correct |
10 ms |
3832 KB |
Output is correct |
44 |
Correct |
76 ms |
4796 KB |
Output is correct |
45 |
Correct |
2 ms |
2636 KB |
Output is correct |
46 |
Correct |
14 ms |
3788 KB |
Output is correct |
47 |
Correct |
27 ms |
5068 KB |
Output is correct |
48 |
Correct |
14 ms |
3784 KB |
Output is correct |
49 |
Correct |
27 ms |
5068 KB |
Output is correct |
50 |
Correct |
28 ms |
5028 KB |
Output is correct |
51 |
Correct |
248 ms |
7388 KB |
Output is correct |
52 |
Correct |
6 ms |
3148 KB |
Output is correct |
53 |
Correct |
492 ms |
7864 KB |
Output is correct |
54 |
Correct |
544 ms |
7920 KB |
Output is correct |
55 |
Correct |
6 ms |
3148 KB |
Output is correct |
56 |
Correct |
6 ms |
3148 KB |
Output is correct |
57 |
Correct |
2 ms |
2764 KB |
Output is correct |
58 |
Correct |
490 ms |
7872 KB |
Output is correct |
59 |
Correct |
11 ms |
3660 KB |
Output is correct |
60 |
Correct |
8 ms |
3188 KB |
Output is correct |
61 |
Correct |
11 ms |
3780 KB |
Output is correct |
62 |
Correct |
11 ms |
3772 KB |
Output is correct |
63 |
Correct |
75 ms |
4692 KB |
Output is correct |
64 |
Correct |
41 ms |
4496 KB |
Output is correct |
65 |
Correct |
9 ms |
3660 KB |
Output is correct |
66 |
Correct |
11 ms |
3660 KB |
Output is correct |
67 |
Correct |
59 ms |
5468 KB |
Output is correct |
68 |
Correct |
41 ms |
4428 KB |
Output is correct |
69 |
Correct |
10 ms |
3704 KB |
Output is correct |
70 |
Correct |
24 ms |
4704 KB |
Output is correct |
71 |
Correct |
57 ms |
5316 KB |
Output is correct |
72 |
Correct |
49 ms |
5380 KB |
Output is correct |
73 |
Correct |
6 ms |
3148 KB |
Output is correct |
74 |
Correct |
24 ms |
4688 KB |
Output is correct |
75 |
Correct |
48 ms |
5404 KB |
Output is correct |
76 |
Correct |
15 ms |
4256 KB |
Output is correct |
77 |
Correct |
93 ms |
5956 KB |
Output is correct |
78 |
Correct |
8 ms |
3148 KB |
Output is correct |
79 |
Correct |
48 ms |
4244 KB |
Output is correct |
80 |
Correct |
20 ms |
4116 KB |
Output is correct |
81 |
Correct |
94 ms |
5956 KB |
Output is correct |
82 |
Correct |
4 ms |
2892 KB |
Output is correct |
83 |
Correct |
51 ms |
4240 KB |
Output is correct |
84 |
Correct |
45 ms |
5304 KB |
Output is correct |
85 |
Correct |
4 ms |
2936 KB |
Output is correct |
86 |
Correct |
44 ms |
5324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3148 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
11 |
Correct |
6 ms |
3148 KB |
Output is correct |
12 |
Correct |
7 ms |
3260 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
6 ms |
3188 KB |
Output is correct |
15 |
Correct |
2 ms |
2636 KB |
Output is correct |
16 |
Correct |
6 ms |
3260 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
7 ms |
3264 KB |
Output is correct |
19 |
Correct |
3 ms |
2764 KB |
Output is correct |
20 |
Correct |
4 ms |
2932 KB |
Output is correct |
21 |
Correct |
4 ms |
2892 KB |
Output is correct |
22 |
Correct |
2 ms |
2764 KB |
Output is correct |
23 |
Correct |
8 ms |
3320 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
8 ms |
3276 KB |
Output is correct |
26 |
Correct |
7 ms |
3228 KB |
Output is correct |
27 |
Correct |
5 ms |
3148 KB |
Output is correct |
28 |
Correct |
7 ms |
3276 KB |
Output is correct |
29 |
Correct |
6 ms |
3148 KB |
Output is correct |
30 |
Correct |
8 ms |
3320 KB |
Output is correct |
31 |
Correct |
7 ms |
3328 KB |
Output is correct |
32 |
Correct |
8 ms |
3436 KB |
Output is correct |
33 |
Correct |
10 ms |
3404 KB |
Output is correct |
34 |
Correct |
9 ms |
3412 KB |
Output is correct |
35 |
Correct |
5 ms |
2940 KB |
Output is correct |
36 |
Correct |
5 ms |
2932 KB |
Output is correct |
37 |
Correct |
5 ms |
3020 KB |
Output is correct |
38 |
Correct |
4 ms |
2892 KB |
Output is correct |
39 |
Correct |
5 ms |
2892 KB |
Output is correct |
40 |
Correct |
11 ms |
3792 KB |
Output is correct |
41 |
Correct |
4 ms |
2892 KB |
Output is correct |
42 |
Correct |
11 ms |
3832 KB |
Output is correct |
43 |
Correct |
10 ms |
3832 KB |
Output is correct |
44 |
Correct |
2 ms |
2636 KB |
Output is correct |
45 |
Correct |
215 ms |
20832 KB |
Output is correct |
46 |
Correct |
109 ms |
11280 KB |
Output is correct |
47 |
Correct |
199 ms |
20792 KB |
Output is correct |
48 |
Correct |
213 ms |
20680 KB |
Output is correct |
49 |
Correct |
68 ms |
8540 KB |
Output is correct |
50 |
Correct |
273 ms |
25928 KB |
Output is correct |
51 |
Correct |
201 ms |
20880 KB |
Output is correct |
52 |
Correct |
52 ms |
8592 KB |
Output is correct |
53 |
Correct |
54 ms |
8620 KB |
Output is correct |
54 |
Correct |
12 ms |
3536 KB |
Output is correct |
55 |
Correct |
269 ms |
25984 KB |
Output is correct |
56 |
Correct |
33 ms |
5980 KB |
Output is correct |
57 |
Correct |
52 ms |
8532 KB |
Output is correct |
58 |
Correct |
72 ms |
11164 KB |
Output is correct |
59 |
Correct |
30 ms |
5896 KB |
Output is correct |
60 |
Correct |
35 ms |
5984 KB |
Output is correct |
61 |
Correct |
71 ms |
11144 KB |
Output is correct |
62 |
Correct |
49 ms |
8612 KB |
Output is correct |
63 |
Correct |
98 ms |
13116 KB |
Output is correct |
64 |
Correct |
29 ms |
5880 KB |
Output is correct |
65 |
Correct |
132 ms |
15808 KB |
Output is correct |
66 |
Correct |
50 ms |
8512 KB |
Output is correct |
67 |
Correct |
102 ms |
13116 KB |
Output is correct |
68 |
Correct |
127 ms |
15040 KB |
Output is correct |
69 |
Correct |
131 ms |
15792 KB |
Output is correct |
70 |
Correct |
56 ms |
8588 KB |
Output is correct |
71 |
Correct |
138 ms |
15164 KB |
Output is correct |
72 |
Correct |
106 ms |
12692 KB |
Output is correct |
73 |
Correct |
151 ms |
17432 KB |
Output is correct |
74 |
Correct |
47 ms |
8500 KB |
Output is correct |
75 |
Correct |
52 ms |
8428 KB |
Output is correct |
76 |
Correct |
125 ms |
12764 KB |
Output is correct |
77 |
Correct |
157 ms |
17516 KB |
Output is correct |
78 |
Correct |
69 ms |
9956 KB |
Output is correct |
79 |
Correct |
49 ms |
8392 KB |
Output is correct |
80 |
Correct |
24 ms |
5564 KB |
Output is correct |
81 |
Correct |
71 ms |
10048 KB |
Output is correct |
82 |
Correct |
115 ms |
14392 KB |
Output is correct |
83 |
Correct |
25 ms |
5452 KB |
Output is correct |
84 |
Correct |
109 ms |
14424 KB |
Output is correct |