#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(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});
} cnt[i] = 0;
}
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 |
1 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 |
1344 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1212 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
316 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1344 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1212 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
316 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
1236 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 |
0 ms |
320 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
984 KB |
Output is correct |
21 |
Correct |
3 ms |
980 KB |
Output is correct |
22 |
Correct |
2 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 |
6 ms |
1364 KB |
Output is correct |
26 |
Correct |
6 ms |
1364 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1364 KB |
Output is correct |
29 |
Correct |
4 ms |
1236 KB |
Output is correct |
30 |
Correct |
7 ms |
1496 KB |
Output is correct |
31 |
Correct |
6 ms |
1492 KB |
Output is correct |
32 |
Correct |
6 ms |
1492 KB |
Output is correct |
33 |
Correct |
7 ms |
1484 KB |
Output is correct |
34 |
Correct |
6 ms |
1492 KB |
Output is correct |
35 |
Correct |
3 ms |
852 KB |
Output is correct |
36 |
Correct |
4 ms |
852 KB |
Output is correct |
37 |
Correct |
4 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
584 KB |
Output is correct |
39 |
Correct |
3 ms |
596 KB |
Output is correct |
40 |
Correct |
9 ms |
1748 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
9 ms |
1748 KB |
Output is correct |
43 |
Correct |
9 ms |
1740 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 |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
252 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
474 ms |
26988 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
528 ms |
26984 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
486 ms |
26980 KB |
Output is correct |
16 |
Correct |
482 ms |
26980 KB |
Output is correct |
17 |
Correct |
491 ms |
27056 KB |
Output is correct |
18 |
Correct |
487 ms |
26908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1344 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1212 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
316 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
1236 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 |
0 ms |
320 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
984 KB |
Output is correct |
21 |
Correct |
3 ms |
980 KB |
Output is correct |
22 |
Correct |
2 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 |
6 ms |
1364 KB |
Output is correct |
26 |
Correct |
6 ms |
1364 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1364 KB |
Output is correct |
29 |
Correct |
4 ms |
1236 KB |
Output is correct |
30 |
Correct |
7 ms |
1496 KB |
Output is correct |
31 |
Correct |
6 ms |
1492 KB |
Output is correct |
32 |
Correct |
6 ms |
1492 KB |
Output is correct |
33 |
Correct |
7 ms |
1484 KB |
Output is correct |
34 |
Correct |
6 ms |
1492 KB |
Output is correct |
35 |
Correct |
3 ms |
852 KB |
Output is correct |
36 |
Correct |
4 ms |
852 KB |
Output is correct |
37 |
Correct |
4 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
584 KB |
Output is correct |
39 |
Correct |
3 ms |
596 KB |
Output is correct |
40 |
Correct |
9 ms |
1748 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
9 ms |
1748 KB |
Output is correct |
43 |
Correct |
9 ms |
1740 KB |
Output is correct |
44 |
Correct |
61 ms |
2900 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
10 ms |
1748 KB |
Output is correct |
47 |
Correct |
25 ms |
2772 KB |
Output is correct |
48 |
Correct |
9 ms |
1748 KB |
Output is correct |
49 |
Correct |
23 ms |
2896 KB |
Output is correct |
50 |
Correct |
25 ms |
2772 KB |
Output is correct |
51 |
Correct |
205 ms |
4948 KB |
Output is correct |
52 |
Correct |
4 ms |
1236 KB |
Output is correct |
53 |
Correct |
391 ms |
5456 KB |
Output is correct |
54 |
Correct |
411 ms |
5460 KB |
Output is correct |
55 |
Correct |
6 ms |
1236 KB |
Output is correct |
56 |
Correct |
5 ms |
1228 KB |
Output is correct |
57 |
Correct |
2 ms |
716 KB |
Output is correct |
58 |
Correct |
385 ms |
5388 KB |
Output is correct |
59 |
Correct |
9 ms |
1732 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 |
60 ms |
2772 KB |
Output is correct |
64 |
Correct |
34 ms |
2520 KB |
Output is correct |
65 |
Correct |
10 ms |
1688 KB |
Output is correct |
66 |
Correct |
9 ms |
1748 KB |
Output is correct |
67 |
Correct |
50 ms |
3272 KB |
Output is correct |
68 |
Correct |
33 ms |
2516 KB |
Output is correct |
69 |
Correct |
8 ms |
1620 KB |
Output is correct |
70 |
Correct |
21 ms |
2644 KB |
Output is correct |
71 |
Correct |
49 ms |
3156 KB |
Output is correct |
72 |
Correct |
40 ms |
3144 KB |
Output is correct |
73 |
Correct |
5 ms |
1236 KB |
Output is correct |
74 |
Correct |
22 ms |
2700 KB |
Output is correct |
75 |
Correct |
41 ms |
3112 KB |
Output is correct |
76 |
Correct |
15 ms |
2132 KB |
Output is correct |
77 |
Correct |
85 ms |
3668 KB |
Output is correct |
78 |
Correct |
4 ms |
1236 KB |
Output is correct |
79 |
Correct |
42 ms |
2028 KB |
Output is correct |
80 |
Correct |
13 ms |
2132 KB |
Output is correct |
81 |
Correct |
85 ms |
3668 KB |
Output is correct |
82 |
Correct |
3 ms |
596 KB |
Output is correct |
83 |
Correct |
44 ms |
2124 KB |
Output is correct |
84 |
Correct |
40 ms |
3028 KB |
Output is correct |
85 |
Correct |
2 ms |
584 KB |
Output is correct |
86 |
Incorrect |
40 ms |
3032 KB |
Output isn't correct |
87 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1344 KB |
Output is correct |
5 |
Correct |
4 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1212 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
316 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
1236 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 |
0 ms |
320 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
984 KB |
Output is correct |
21 |
Correct |
3 ms |
980 KB |
Output is correct |
22 |
Correct |
2 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 |
6 ms |
1364 KB |
Output is correct |
26 |
Correct |
6 ms |
1364 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
5 ms |
1364 KB |
Output is correct |
29 |
Correct |
4 ms |
1236 KB |
Output is correct |
30 |
Correct |
7 ms |
1496 KB |
Output is correct |
31 |
Correct |
6 ms |
1492 KB |
Output is correct |
32 |
Correct |
6 ms |
1492 KB |
Output is correct |
33 |
Correct |
7 ms |
1484 KB |
Output is correct |
34 |
Correct |
6 ms |
1492 KB |
Output is correct |
35 |
Correct |
3 ms |
852 KB |
Output is correct |
36 |
Correct |
4 ms |
852 KB |
Output is correct |
37 |
Correct |
4 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
584 KB |
Output is correct |
39 |
Correct |
3 ms |
596 KB |
Output is correct |
40 |
Correct |
9 ms |
1748 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
9 ms |
1748 KB |
Output is correct |
43 |
Correct |
9 ms |
1740 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
203 ms |
19848 KB |
Output is correct |
46 |
Correct |
84 ms |
12892 KB |
Output is correct |
47 |
Correct |
211 ms |
19952 KB |
Output is correct |
48 |
Correct |
201 ms |
19884 KB |
Output is correct |
49 |
Correct |
51 ms |
10540 KB |
Output is correct |
50 |
Correct |
220 ms |
24624 KB |
Output is correct |
51 |
Correct |
211 ms |
20004 KB |
Output is correct |
52 |
Correct |
54 ms |
10540 KB |
Output is correct |
53 |
Correct |
52 ms |
10460 KB |
Output is correct |
54 |
Correct |
14 ms |
5192 KB |
Output is correct |
55 |
Correct |
235 ms |
24504 KB |
Output is correct |
56 |
Correct |
31 ms |
7892 KB |
Output is correct |
57 |
Correct |
49 ms |
10444 KB |
Output is correct |
58 |
Correct |
71 ms |
12772 KB |
Output is correct |
59 |
Correct |
30 ms |
7880 KB |
Output is correct |
60 |
Correct |
29 ms |
7892 KB |
Output is correct |
61 |
Correct |
74 ms |
12792 KB |
Output is correct |
62 |
Correct |
50 ms |
10532 KB |
Output is correct |
63 |
Correct |
112 ms |
14096 KB |
Output is correct |
64 |
Correct |
35 ms |
7880 KB |
Output is correct |
65 |
Correct |
144 ms |
16424 KB |
Output is correct |
66 |
Correct |
49 ms |
10536 KB |
Output is correct |
67 |
Correct |
111 ms |
14032 KB |
Output is correct |
68 |
Correct |
145 ms |
15812 KB |
Output is correct |
69 |
Correct |
148 ms |
16360 KB |
Output is correct |
70 |
Correct |
54 ms |
10444 KB |
Output is correct |
71 |
Correct |
136 ms |
15764 KB |
Output is correct |
72 |
Correct |
100 ms |
13660 KB |
Output is correct |
73 |
Correct |
162 ms |
17868 KB |
Output is correct |
74 |
Correct |
54 ms |
10492 KB |
Output is correct |
75 |
Correct |
53 ms |
7908 KB |
Output is correct |
76 |
Correct |
103 ms |
13644 KB |
Output is correct |
77 |
Correct |
186 ms |
17920 KB |
Output is correct |
78 |
Correct |
82 ms |
9276 KB |
Output is correct |
79 |
Correct |
53 ms |
7708 KB |
Output is correct |
80 |
Correct |
23 ms |
3924 KB |
Output is correct |
81 |
Correct |
78 ms |
9212 KB |
Output is correct |
82 |
Correct |
126 ms |
15092 KB |
Output is correct |
83 |
Correct |
23 ms |
4012 KB |
Output is correct |
84 |
Incorrect |
120 ms |
15112 KB |
Output isn't correct |
85 |
Halted |
0 ms |
0 KB |
- |