#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pw(x) (1ll << x)
#define sz(x) (int)((x).size())
#define pb push_back
#define endl '\n'
#define mp make_pair
#define vec vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef unsigned long long ull;
typedef unsigned int uint;
template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T>
using oset = tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
inline void solve () {
int n, k; cin >> n >> k;
vector <int> cnt (n);
vector <set <int>> g (n);
for (int i = 0; i < n; ++i) {
cin >> cnt[i];
for (int j = 0; j < cnt[i]; ++j) {
int x; cin >> x;
g[i].insert(x);
}
}
int ans = 0;
set <pii> s; for (int i = 0; i < n; ++i) s.insert({cnt[i], i});
while (sz(s)) {
auto [_, i] = *s.begin(); s.erase(s.begin());
vector <int> ar;
for (auto j : g[i]) ar.pb(j);
for (int msk = 0; msk < pw(sz(ar)); ++msk) {
vector <int> b;
for (int j = 0; j < sz(ar); ++j) if (msk >> j & 1) b.pb(ar[j]);
bool okich = 1;
for (int i = 0; i < sz(b) && okich; ++i) {
for (int j = i + 1; j < sz(b) && okich; ++j) {
if (g[b[i]].find(b[j]) == g[b[i]].end()) okich = 0;
}
}
if (okich) umax(ans, __builtin_popcount(msk));
}
for (auto j : g[i]) {
s.erase({sz(g[j]), j});
g[j].erase(i);
s.insert({sz(g[j]), j});
}
}
cout << ans + 1 << endl;
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t = 1; // cin >> t;
while (t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
5 ms |
1236 KB |
Output is correct |
4 |
Correct |
4 ms |
1236 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
4 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
5 ms |
1236 KB |
Output is correct |
4 |
Correct |
4 ms |
1236 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
4 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
1236 KB |
Output is correct |
12 |
Correct |
6 ms |
1236 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
1236 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
3 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
6 ms |
1364 KB |
Output is correct |
24 |
Correct |
2 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
1364 KB |
Output is correct |
26 |
Correct |
5 ms |
1236 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1236 KB |
Output is correct |
29 |
Correct |
4 ms |
1236 KB |
Output is correct |
30 |
Correct |
6 ms |
1364 KB |
Output is correct |
31 |
Correct |
6 ms |
1364 KB |
Output is correct |
32 |
Correct |
6 ms |
1364 KB |
Output is correct |
33 |
Correct |
6 ms |
1364 KB |
Output is correct |
34 |
Correct |
6 ms |
1364 KB |
Output is correct |
35 |
Correct |
3 ms |
852 KB |
Output is correct |
36 |
Correct |
3 ms |
852 KB |
Output is correct |
37 |
Correct |
3 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
10 ms |
1748 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
10 ms |
1748 KB |
Output is correct |
43 |
Correct |
10 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
487 ms |
26336 KB |
Output is correct |
12 |
Correct |
0 ms |
224 KB |
Output is correct |
13 |
Correct |
499 ms |
26336 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
491 ms |
26352 KB |
Output is correct |
16 |
Correct |
488 ms |
26344 KB |
Output is correct |
17 |
Correct |
512 ms |
26340 KB |
Output is correct |
18 |
Correct |
497 ms |
26372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
5 ms |
1236 KB |
Output is correct |
4 |
Correct |
4 ms |
1236 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
4 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
1236 KB |
Output is correct |
12 |
Correct |
6 ms |
1236 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
1236 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
3 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
6 ms |
1364 KB |
Output is correct |
24 |
Correct |
2 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
1364 KB |
Output is correct |
26 |
Correct |
5 ms |
1236 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1236 KB |
Output is correct |
29 |
Correct |
4 ms |
1236 KB |
Output is correct |
30 |
Correct |
6 ms |
1364 KB |
Output is correct |
31 |
Correct |
6 ms |
1364 KB |
Output is correct |
32 |
Correct |
6 ms |
1364 KB |
Output is correct |
33 |
Correct |
6 ms |
1364 KB |
Output is correct |
34 |
Correct |
6 ms |
1364 KB |
Output is correct |
35 |
Correct |
3 ms |
852 KB |
Output is correct |
36 |
Correct |
3 ms |
852 KB |
Output is correct |
37 |
Correct |
3 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
10 ms |
1748 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
10 ms |
1748 KB |
Output is correct |
43 |
Correct |
10 ms |
1748 KB |
Output is correct |
44 |
Correct |
67 ms |
2644 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
10 ms |
1692 KB |
Output is correct |
47 |
Correct |
24 ms |
2644 KB |
Output is correct |
48 |
Correct |
9 ms |
1620 KB |
Output is correct |
49 |
Correct |
28 ms |
2680 KB |
Output is correct |
50 |
Correct |
28 ms |
2644 KB |
Output is correct |
51 |
Correct |
219 ms |
4564 KB |
Output is correct |
52 |
Correct |
5 ms |
1236 KB |
Output is correct |
53 |
Correct |
401 ms |
4948 KB |
Output is correct |
54 |
Correct |
426 ms |
4948 KB |
Output is correct |
55 |
Correct |
5 ms |
1236 KB |
Output is correct |
56 |
Correct |
5 ms |
1236 KB |
Output is correct |
57 |
Correct |
2 ms |
724 KB |
Output is correct |
58 |
Correct |
414 ms |
4940 KB |
Output is correct |
59 |
Correct |
9 ms |
1748 KB |
Output is correct |
60 |
Correct |
5 ms |
1236 KB |
Output is correct |
61 |
Correct |
9 ms |
1748 KB |
Output is correct |
62 |
Correct |
9 ms |
1748 KB |
Output is correct |
63 |
Correct |
68 ms |
2588 KB |
Output is correct |
64 |
Correct |
38 ms |
2388 KB |
Output is correct |
65 |
Correct |
8 ms |
1620 KB |
Output is correct |
66 |
Correct |
9 ms |
1748 KB |
Output is correct |
67 |
Correct |
54 ms |
3028 KB |
Output is correct |
68 |
Correct |
36 ms |
2388 KB |
Output is correct |
69 |
Correct |
8 ms |
1620 KB |
Output is correct |
70 |
Correct |
21 ms |
2436 KB |
Output is correct |
71 |
Correct |
58 ms |
3028 KB |
Output is correct |
72 |
Correct |
41 ms |
2900 KB |
Output is correct |
73 |
Correct |
4 ms |
1236 KB |
Output is correct |
74 |
Correct |
22 ms |
2516 KB |
Output is correct |
75 |
Correct |
42 ms |
2900 KB |
Output is correct |
76 |
Correct |
13 ms |
1944 KB |
Output is correct |
77 |
Correct |
84 ms |
3412 KB |
Output is correct |
78 |
Correct |
4 ms |
1236 KB |
Output is correct |
79 |
Correct |
45 ms |
1876 KB |
Output is correct |
80 |
Correct |
13 ms |
2004 KB |
Output is correct |
81 |
Correct |
85 ms |
3412 KB |
Output is correct |
82 |
Correct |
2 ms |
596 KB |
Output is correct |
83 |
Correct |
42 ms |
1876 KB |
Output is correct |
84 |
Correct |
40 ms |
2900 KB |
Output is correct |
85 |
Correct |
2 ms |
548 KB |
Output is correct |
86 |
Correct |
40 ms |
2900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
5 ms |
1236 KB |
Output is correct |
4 |
Correct |
4 ms |
1236 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
4 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
1236 KB |
Output is correct |
12 |
Correct |
6 ms |
1236 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
1236 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
3 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
6 ms |
1364 KB |
Output is correct |
24 |
Correct |
2 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
1364 KB |
Output is correct |
26 |
Correct |
5 ms |
1236 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1236 KB |
Output is correct |
29 |
Correct |
4 ms |
1236 KB |
Output is correct |
30 |
Correct |
6 ms |
1364 KB |
Output is correct |
31 |
Correct |
6 ms |
1364 KB |
Output is correct |
32 |
Correct |
6 ms |
1364 KB |
Output is correct |
33 |
Correct |
6 ms |
1364 KB |
Output is correct |
34 |
Correct |
6 ms |
1364 KB |
Output is correct |
35 |
Correct |
3 ms |
852 KB |
Output is correct |
36 |
Correct |
3 ms |
852 KB |
Output is correct |
37 |
Correct |
3 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
10 ms |
1748 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
10 ms |
1748 KB |
Output is correct |
43 |
Correct |
10 ms |
1748 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
196 ms |
19360 KB |
Output is correct |
46 |
Correct |
79 ms |
12240 KB |
Output is correct |
47 |
Correct |
201 ms |
19184 KB |
Output is correct |
48 |
Correct |
198 ms |
19404 KB |
Output is correct |
49 |
Correct |
50 ms |
9836 KB |
Output is correct |
50 |
Correct |
224 ms |
23924 KB |
Output is correct |
51 |
Correct |
211 ms |
19172 KB |
Output is correct |
52 |
Correct |
52 ms |
9932 KB |
Output is correct |
53 |
Correct |
54 ms |
9864 KB |
Output is correct |
54 |
Correct |
13 ms |
5204 KB |
Output is correct |
55 |
Correct |
229 ms |
23976 KB |
Output is correct |
56 |
Correct |
28 ms |
7560 KB |
Output is correct |
57 |
Correct |
48 ms |
9908 KB |
Output is correct |
58 |
Correct |
68 ms |
12188 KB |
Output is correct |
59 |
Correct |
28 ms |
7508 KB |
Output is correct |
60 |
Correct |
30 ms |
7508 KB |
Output is correct |
61 |
Correct |
68 ms |
12252 KB |
Output is correct |
62 |
Correct |
49 ms |
9820 KB |
Output is correct |
63 |
Correct |
102 ms |
13432 KB |
Output is correct |
64 |
Correct |
29 ms |
7504 KB |
Output is correct |
65 |
Correct |
148 ms |
15740 KB |
Output is correct |
66 |
Correct |
49 ms |
9812 KB |
Output is correct |
67 |
Correct |
102 ms |
13516 KB |
Output is correct |
68 |
Correct |
133 ms |
15188 KB |
Output is correct |
69 |
Correct |
151 ms |
15756 KB |
Output is correct |
70 |
Correct |
49 ms |
9836 KB |
Output is correct |
71 |
Correct |
133 ms |
15192 KB |
Output is correct |
72 |
Correct |
104 ms |
13012 KB |
Output is correct |
73 |
Correct |
158 ms |
17148 KB |
Output is correct |
74 |
Correct |
50 ms |
9812 KB |
Output is correct |
75 |
Correct |
52 ms |
7252 KB |
Output is correct |
76 |
Correct |
102 ms |
13076 KB |
Output is correct |
77 |
Correct |
162 ms |
17276 KB |
Output is correct |
78 |
Correct |
80 ms |
8788 KB |
Output is correct |
79 |
Correct |
52 ms |
7220 KB |
Output is correct |
80 |
Correct |
22 ms |
3748 KB |
Output is correct |
81 |
Correct |
82 ms |
8672 KB |
Output is correct |
82 |
Correct |
123 ms |
14604 KB |
Output is correct |
83 |
Correct |
23 ms |
3760 KB |
Output is correct |
84 |
Correct |
130 ms |
14592 KB |
Output is correct |