#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) {
if (__builtin_popcount(msk) <= ans) continue;
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(ar[j]) == g[b[i]].end()) okich = 0;
}
}
if (okich) umax(ans, __builtin_popcount(msk));
}
for (auto j : g[i]) {
s.erase({cnt[j], j});
--cnt[j]; g[j].erase(i);
s.insert({cnt[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 |
0 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 |
0 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 |
1244 KB |
Output is correct |
12 |
Correct |
4 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 |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
5 ms |
1220 KB |
Output is correct |
17 |
Correct |
1 ms |
276 KB |
Output is correct |
18 |
Correct |
5 ms |
1232 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 |
1 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
1364 KB |
Output is correct |
26 |
Correct |
6 ms |
1416 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1364 KB |
Output is correct |
29 |
Correct |
5 ms |
1232 KB |
Output is correct |
30 |
Correct |
7 ms |
1492 KB |
Output is correct |
31 |
Correct |
7 ms |
1492 KB |
Output is correct |
32 |
Correct |
6 ms |
1484 KB |
Output is correct |
33 |
Correct |
7 ms |
1492 KB |
Output is correct |
34 |
Correct |
6 ms |
1488 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 |
3 ms |
596 KB |
Output is correct |
40 |
Correct |
9 ms |
1748 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
9 ms |
1748 KB |
Output is correct |
43 |
Correct |
9 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
0 ms |
316 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
439 ms |
28976 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
435 ms |
28940 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
429 ms |
29096 KB |
Output is correct |
16 |
Correct |
423 ms |
28876 KB |
Output is correct |
17 |
Correct |
438 ms |
29016 KB |
Output is correct |
18 |
Correct |
435 ms |
28988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
1244 KB |
Output is correct |
12 |
Correct |
4 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 |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
5 ms |
1220 KB |
Output is correct |
17 |
Correct |
1 ms |
276 KB |
Output is correct |
18 |
Correct |
5 ms |
1232 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 |
1 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
1364 KB |
Output is correct |
26 |
Correct |
6 ms |
1416 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1364 KB |
Output is correct |
29 |
Correct |
5 ms |
1232 KB |
Output is correct |
30 |
Correct |
7 ms |
1492 KB |
Output is correct |
31 |
Correct |
7 ms |
1492 KB |
Output is correct |
32 |
Correct |
6 ms |
1484 KB |
Output is correct |
33 |
Correct |
7 ms |
1492 KB |
Output is correct |
34 |
Correct |
6 ms |
1488 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 |
3 ms |
596 KB |
Output is correct |
40 |
Correct |
9 ms |
1748 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
9 ms |
1748 KB |
Output is correct |
43 |
Correct |
9 ms |
1784 KB |
Output is correct |
44 |
Correct |
14 ms |
2772 KB |
Output is correct |
45 |
Correct |
0 ms |
328 KB |
Output is correct |
46 |
Correct |
9 ms |
1868 KB |
Output is correct |
47 |
Correct |
20 ms |
2772 KB |
Output is correct |
48 |
Correct |
8 ms |
1748 KB |
Output is correct |
49 |
Correct |
20 ms |
2804 KB |
Output is correct |
50 |
Correct |
20 ms |
2772 KB |
Output is correct |
51 |
Correct |
193 ms |
4848 KB |
Output is correct |
52 |
Correct |
4 ms |
1220 KB |
Output is correct |
53 |
Correct |
392 ms |
5340 KB |
Output is correct |
54 |
Correct |
375 ms |
5460 KB |
Output is correct |
55 |
Correct |
5 ms |
1236 KB |
Output is correct |
56 |
Correct |
5 ms |
1236 KB |
Output is correct |
57 |
Correct |
1 ms |
724 KB |
Output is correct |
58 |
Correct |
388 ms |
5388 KB |
Output is correct |
59 |
Correct |
6 ms |
1748 KB |
Output is correct |
60 |
Correct |
5 ms |
1360 KB |
Output is correct |
61 |
Correct |
8 ms |
1748 KB |
Output is correct |
62 |
Correct |
8 ms |
1748 KB |
Output is correct |
63 |
Correct |
14 ms |
2820 KB |
Output is correct |
64 |
Correct |
14 ms |
2584 KB |
Output is correct |
65 |
Correct |
8 ms |
1620 KB |
Output is correct |
66 |
Correct |
7 ms |
1748 KB |
Output is correct |
67 |
Correct |
40 ms |
3320 KB |
Output is correct |
68 |
Correct |
14 ms |
2516 KB |
Output is correct |
69 |
Correct |
7 ms |
1620 KB |
Output is correct |
70 |
Correct |
15 ms |
2644 KB |
Output is correct |
71 |
Correct |
41 ms |
3156 KB |
Output is correct |
72 |
Correct |
28 ms |
3156 KB |
Output is correct |
73 |
Correct |
4 ms |
1232 KB |
Output is correct |
74 |
Correct |
16 ms |
2644 KB |
Output is correct |
75 |
Correct |
29 ms |
3156 KB |
Output is correct |
76 |
Correct |
12 ms |
2132 KB |
Output is correct |
77 |
Correct |
84 ms |
3748 KB |
Output is correct |
78 |
Correct |
4 ms |
1236 KB |
Output is correct |
79 |
Correct |
42 ms |
2004 KB |
Output is correct |
80 |
Correct |
11 ms |
2132 KB |
Output is correct |
81 |
Correct |
89 ms |
3796 KB |
Output is correct |
82 |
Correct |
2 ms |
596 KB |
Output is correct |
83 |
Correct |
41 ms |
2004 KB |
Output is correct |
84 |
Correct |
34 ms |
3028 KB |
Output is correct |
85 |
Correct |
2 ms |
616 KB |
Output is correct |
86 |
Incorrect |
29 ms |
3148 KB |
Output isn't correct |
87 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
1244 KB |
Output is correct |
12 |
Correct |
4 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 |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
5 ms |
1220 KB |
Output is correct |
17 |
Correct |
1 ms |
276 KB |
Output is correct |
18 |
Correct |
5 ms |
1232 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 |
1 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
1364 KB |
Output is correct |
26 |
Correct |
6 ms |
1416 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1364 KB |
Output is correct |
29 |
Correct |
5 ms |
1232 KB |
Output is correct |
30 |
Correct |
7 ms |
1492 KB |
Output is correct |
31 |
Correct |
7 ms |
1492 KB |
Output is correct |
32 |
Correct |
6 ms |
1484 KB |
Output is correct |
33 |
Correct |
7 ms |
1492 KB |
Output is correct |
34 |
Correct |
6 ms |
1488 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 |
3 ms |
596 KB |
Output is correct |
40 |
Correct |
9 ms |
1748 KB |
Output is correct |
41 |
Correct |
3 ms |
596 KB |
Output is correct |
42 |
Correct |
9 ms |
1748 KB |
Output is correct |
43 |
Correct |
9 ms |
1784 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
182 ms |
21208 KB |
Output is correct |
46 |
Correct |
75 ms |
13184 KB |
Output is correct |
47 |
Correct |
182 ms |
21092 KB |
Output is correct |
48 |
Correct |
189 ms |
21212 KB |
Output is correct |
49 |
Correct |
49 ms |
10532 KB |
Output is correct |
50 |
Correct |
214 ms |
26316 KB |
Output is correct |
51 |
Correct |
183 ms |
21068 KB |
Output is correct |
52 |
Correct |
49 ms |
10516 KB |
Output is correct |
53 |
Correct |
48 ms |
10516 KB |
Output is correct |
54 |
Correct |
15 ms |
5204 KB |
Output is correct |
55 |
Correct |
227 ms |
26300 KB |
Output is correct |
56 |
Correct |
28 ms |
7892 KB |
Output is correct |
57 |
Correct |
52 ms |
10556 KB |
Output is correct |
58 |
Correct |
63 ms |
13108 KB |
Output is correct |
59 |
Correct |
30 ms |
7892 KB |
Output is correct |
60 |
Correct |
30 ms |
7884 KB |
Output is correct |
61 |
Correct |
62 ms |
13132 KB |
Output is correct |
62 |
Correct |
47 ms |
10572 KB |
Output is correct |
63 |
Correct |
102 ms |
14488 KB |
Output is correct |
64 |
Correct |
29 ms |
7892 KB |
Output is correct |
65 |
Correct |
130 ms |
17156 KB |
Output is correct |
66 |
Correct |
46 ms |
10580 KB |
Output is correct |
67 |
Correct |
105 ms |
14544 KB |
Output is correct |
68 |
Correct |
122 ms |
16472 KB |
Output is correct |
69 |
Correct |
127 ms |
17108 KB |
Output is correct |
70 |
Correct |
50 ms |
10492 KB |
Output is correct |
71 |
Correct |
140 ms |
16588 KB |
Output is correct |
72 |
Correct |
95 ms |
13972 KB |
Output is correct |
73 |
Correct |
158 ms |
18764 KB |
Output is correct |
74 |
Correct |
53 ms |
10572 KB |
Output is correct |
75 |
Correct |
54 ms |
7884 KB |
Output is correct |
76 |
Correct |
100 ms |
14080 KB |
Output is correct |
77 |
Correct |
165 ms |
18784 KB |
Output is correct |
78 |
Correct |
79 ms |
9420 KB |
Output is correct |
79 |
Correct |
53 ms |
7812 KB |
Output is correct |
80 |
Correct |
22 ms |
4052 KB |
Output is correct |
81 |
Correct |
76 ms |
9516 KB |
Output is correct |
82 |
Correct |
114 ms |
15832 KB |
Output is correct |
83 |
Correct |
24 ms |
4036 KB |
Output is correct |
84 |
Incorrect |
116 ms |
15780 KB |
Output isn't correct |
85 |
Halted |
0 ms |
0 KB |
- |