#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 5e4+10;
int n, k, gr[maxn];
vector<int> g[maxn];
set<int> stg[maxn];
void solve() {
cin >> n >> k;
int ans = 1;
for(int i = 0; i < n; i++) {
int d; cin >> d;
gr[i] = d;
if(d != 0) ans = 2;
while(d--) {
int x; cin >> x;
stg[i].insert(x);
g[i].pb(x);
}
}
set<pair<int,int>> st;
for(int i = 0; i < n; i++) {
st.insert(mp(gr[i],i));
}
while(st.size()) {
int u = st.begin()->sc;
st.erase(st.begin());
if(gr[u]+1 <= k) {
bool ok = true;
for(auto v1 : stg[u]) {
for(auto v2 : stg[u]) {
if(v1 != v2 && stg[v1].count(v2) == 0) ok = false;
}
}
if(ok) ans = max(ans, gr[u]+1);
}
for(auto v : stg[u]) {
stg[v].erase(u);
st.erase(mp(gr[v],v));
--gr[v];
st.insert(mp(gr[v],v));
}
}
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
int tt = 1;
// cin >> tt;
while(tt--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3796 KB |
Output is correct |
2 |
Correct |
2 ms |
3860 KB |
Output is correct |
3 |
Correct |
7 ms |
4864 KB |
Output is correct |
4 |
Correct |
6 ms |
4876 KB |
Output is correct |
5 |
Correct |
7 ms |
4820 KB |
Output is correct |
6 |
Correct |
9 ms |
4792 KB |
Output is correct |
7 |
Correct |
7 ms |
4844 KB |
Output is correct |
8 |
Correct |
3 ms |
4112 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3796 KB |
Output is correct |
2 |
Correct |
2 ms |
3860 KB |
Output is correct |
3 |
Correct |
7 ms |
4864 KB |
Output is correct |
4 |
Correct |
6 ms |
4876 KB |
Output is correct |
5 |
Correct |
7 ms |
4820 KB |
Output is correct |
6 |
Correct |
9 ms |
4792 KB |
Output is correct |
7 |
Correct |
7 ms |
4844 KB |
Output is correct |
8 |
Correct |
3 ms |
4112 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
11 |
Correct |
7 ms |
4820 KB |
Output is correct |
12 |
Correct |
9 ms |
4848 KB |
Output is correct |
13 |
Correct |
2 ms |
3796 KB |
Output is correct |
14 |
Correct |
7 ms |
4844 KB |
Output is correct |
15 |
Correct |
2 ms |
3844 KB |
Output is correct |
16 |
Correct |
6 ms |
4912 KB |
Output is correct |
17 |
Correct |
3 ms |
3796 KB |
Output is correct |
18 |
Correct |
7 ms |
4876 KB |
Output is correct |
19 |
Correct |
3 ms |
4180 KB |
Output is correct |
20 |
Correct |
5 ms |
4564 KB |
Output is correct |
21 |
Correct |
5 ms |
4564 KB |
Output is correct |
22 |
Correct |
3 ms |
4180 KB |
Output is correct |
23 |
Correct |
8 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4180 KB |
Output is correct |
25 |
Correct |
8 ms |
4948 KB |
Output is correct |
26 |
Correct |
8 ms |
4884 KB |
Output is correct |
27 |
Correct |
6 ms |
4820 KB |
Output is correct |
28 |
Correct |
8 ms |
4924 KB |
Output is correct |
29 |
Correct |
6 ms |
4820 KB |
Output is correct |
30 |
Correct |
9 ms |
4948 KB |
Output is correct |
31 |
Correct |
8 ms |
4948 KB |
Output is correct |
32 |
Correct |
8 ms |
4948 KB |
Output is correct |
33 |
Correct |
9 ms |
4964 KB |
Output is correct |
34 |
Correct |
8 ms |
4920 KB |
Output is correct |
35 |
Correct |
5 ms |
4436 KB |
Output is correct |
36 |
Correct |
5 ms |
4408 KB |
Output is correct |
37 |
Correct |
5 ms |
4436 KB |
Output is correct |
38 |
Correct |
4 ms |
4180 KB |
Output is correct |
39 |
Correct |
4 ms |
4236 KB |
Output is correct |
40 |
Correct |
14 ms |
5328 KB |
Output is correct |
41 |
Correct |
4 ms |
4180 KB |
Output is correct |
42 |
Correct |
12 ms |
5356 KB |
Output is correct |
43 |
Correct |
12 ms |
5384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4180 KB |
Output is correct |
2 |
Correct |
2 ms |
3796 KB |
Output is correct |
3 |
Correct |
2 ms |
3796 KB |
Output is correct |
4 |
Correct |
2 ms |
3796 KB |
Output is correct |
5 |
Correct |
2 ms |
3796 KB |
Output is correct |
6 |
Correct |
2 ms |
3796 KB |
Output is correct |
7 |
Correct |
2 ms |
3796 KB |
Output is correct |
8 |
Correct |
2 ms |
3796 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
2 ms |
3796 KB |
Output is correct |
11 |
Correct |
363 ms |
36368 KB |
Output is correct |
12 |
Correct |
2 ms |
3796 KB |
Output is correct |
13 |
Correct |
313 ms |
36352 KB |
Output is correct |
14 |
Correct |
2 ms |
3840 KB |
Output is correct |
15 |
Correct |
355 ms |
36488 KB |
Output is correct |
16 |
Correct |
316 ms |
36368 KB |
Output is correct |
17 |
Correct |
360 ms |
36372 KB |
Output is correct |
18 |
Correct |
371 ms |
36372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3796 KB |
Output is correct |
2 |
Correct |
2 ms |
3860 KB |
Output is correct |
3 |
Correct |
7 ms |
4864 KB |
Output is correct |
4 |
Correct |
6 ms |
4876 KB |
Output is correct |
5 |
Correct |
7 ms |
4820 KB |
Output is correct |
6 |
Correct |
9 ms |
4792 KB |
Output is correct |
7 |
Correct |
7 ms |
4844 KB |
Output is correct |
8 |
Correct |
3 ms |
4112 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
11 |
Correct |
7 ms |
4820 KB |
Output is correct |
12 |
Correct |
9 ms |
4848 KB |
Output is correct |
13 |
Correct |
2 ms |
3796 KB |
Output is correct |
14 |
Correct |
7 ms |
4844 KB |
Output is correct |
15 |
Correct |
2 ms |
3844 KB |
Output is correct |
16 |
Correct |
6 ms |
4912 KB |
Output is correct |
17 |
Correct |
3 ms |
3796 KB |
Output is correct |
18 |
Correct |
7 ms |
4876 KB |
Output is correct |
19 |
Correct |
3 ms |
4180 KB |
Output is correct |
20 |
Correct |
5 ms |
4564 KB |
Output is correct |
21 |
Correct |
5 ms |
4564 KB |
Output is correct |
22 |
Correct |
3 ms |
4180 KB |
Output is correct |
23 |
Correct |
8 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4180 KB |
Output is correct |
25 |
Correct |
8 ms |
4948 KB |
Output is correct |
26 |
Correct |
8 ms |
4884 KB |
Output is correct |
27 |
Correct |
6 ms |
4820 KB |
Output is correct |
28 |
Correct |
8 ms |
4924 KB |
Output is correct |
29 |
Correct |
6 ms |
4820 KB |
Output is correct |
30 |
Correct |
9 ms |
4948 KB |
Output is correct |
31 |
Correct |
8 ms |
4948 KB |
Output is correct |
32 |
Correct |
8 ms |
4948 KB |
Output is correct |
33 |
Correct |
9 ms |
4964 KB |
Output is correct |
34 |
Correct |
8 ms |
4920 KB |
Output is correct |
35 |
Correct |
5 ms |
4436 KB |
Output is correct |
36 |
Correct |
5 ms |
4408 KB |
Output is correct |
37 |
Correct |
5 ms |
4436 KB |
Output is correct |
38 |
Correct |
4 ms |
4180 KB |
Output is correct |
39 |
Correct |
4 ms |
4236 KB |
Output is correct |
40 |
Correct |
14 ms |
5328 KB |
Output is correct |
41 |
Correct |
4 ms |
4180 KB |
Output is correct |
42 |
Correct |
12 ms |
5356 KB |
Output is correct |
43 |
Correct |
12 ms |
5384 KB |
Output is correct |
44 |
Correct |
22 ms |
6484 KB |
Output is correct |
45 |
Correct |
2 ms |
3796 KB |
Output is correct |
46 |
Correct |
13 ms |
5436 KB |
Output is correct |
47 |
Correct |
22 ms |
6544 KB |
Output is correct |
48 |
Correct |
12 ms |
5444 KB |
Output is correct |
49 |
Correct |
23 ms |
6724 KB |
Output is correct |
50 |
Correct |
22 ms |
6620 KB |
Output is correct |
51 |
Correct |
49 ms |
9228 KB |
Output is correct |
52 |
Correct |
9 ms |
4820 KB |
Output is correct |
53 |
Correct |
45 ms |
9792 KB |
Output is correct |
54 |
Correct |
58 ms |
9888 KB |
Output is correct |
55 |
Correct |
9 ms |
4888 KB |
Output is correct |
56 |
Correct |
10 ms |
4880 KB |
Output is correct |
57 |
Correct |
4 ms |
4180 KB |
Output is correct |
58 |
Correct |
44 ms |
9896 KB |
Output is correct |
59 |
Correct |
10 ms |
5476 KB |
Output is correct |
60 |
Correct |
7 ms |
4948 KB |
Output is correct |
61 |
Correct |
9 ms |
5460 KB |
Output is correct |
62 |
Correct |
9 ms |
5460 KB |
Output is correct |
63 |
Correct |
16 ms |
6552 KB |
Output is correct |
64 |
Correct |
15 ms |
6424 KB |
Output is correct |
65 |
Correct |
11 ms |
5268 KB |
Output is correct |
66 |
Correct |
12 ms |
5392 KB |
Output is correct |
67 |
Correct |
28 ms |
7124 KB |
Output is correct |
68 |
Correct |
16 ms |
6356 KB |
Output is correct |
69 |
Correct |
9 ms |
5204 KB |
Output is correct |
70 |
Correct |
20 ms |
6516 KB |
Output is correct |
71 |
Correct |
32 ms |
7124 KB |
Output is correct |
72 |
Correct |
24 ms |
7036 KB |
Output is correct |
73 |
Correct |
9 ms |
4820 KB |
Output is correct |
74 |
Correct |
20 ms |
6548 KB |
Output is correct |
75 |
Correct |
27 ms |
7124 KB |
Output is correct |
76 |
Correct |
15 ms |
5868 KB |
Output is correct |
77 |
Correct |
40 ms |
7780 KB |
Output is correct |
78 |
Correct |
6 ms |
4888 KB |
Output is correct |
79 |
Correct |
18 ms |
5864 KB |
Output is correct |
80 |
Correct |
14 ms |
5844 KB |
Output is correct |
81 |
Correct |
33 ms |
7888 KB |
Output is correct |
82 |
Correct |
4 ms |
4240 KB |
Output is correct |
83 |
Correct |
16 ms |
5844 KB |
Output is correct |
84 |
Correct |
28 ms |
7224 KB |
Output is correct |
85 |
Correct |
4 ms |
4244 KB |
Output is correct |
86 |
Incorrect |
26 ms |
7212 KB |
Output isn't correct |
87 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3796 KB |
Output is correct |
2 |
Correct |
2 ms |
3860 KB |
Output is correct |
3 |
Correct |
7 ms |
4864 KB |
Output is correct |
4 |
Correct |
6 ms |
4876 KB |
Output is correct |
5 |
Correct |
7 ms |
4820 KB |
Output is correct |
6 |
Correct |
9 ms |
4792 KB |
Output is correct |
7 |
Correct |
7 ms |
4844 KB |
Output is correct |
8 |
Correct |
3 ms |
4112 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
11 |
Correct |
7 ms |
4820 KB |
Output is correct |
12 |
Correct |
9 ms |
4848 KB |
Output is correct |
13 |
Correct |
2 ms |
3796 KB |
Output is correct |
14 |
Correct |
7 ms |
4844 KB |
Output is correct |
15 |
Correct |
2 ms |
3844 KB |
Output is correct |
16 |
Correct |
6 ms |
4912 KB |
Output is correct |
17 |
Correct |
3 ms |
3796 KB |
Output is correct |
18 |
Correct |
7 ms |
4876 KB |
Output is correct |
19 |
Correct |
3 ms |
4180 KB |
Output is correct |
20 |
Correct |
5 ms |
4564 KB |
Output is correct |
21 |
Correct |
5 ms |
4564 KB |
Output is correct |
22 |
Correct |
3 ms |
4180 KB |
Output is correct |
23 |
Correct |
8 ms |
4948 KB |
Output is correct |
24 |
Correct |
3 ms |
4180 KB |
Output is correct |
25 |
Correct |
8 ms |
4948 KB |
Output is correct |
26 |
Correct |
8 ms |
4884 KB |
Output is correct |
27 |
Correct |
6 ms |
4820 KB |
Output is correct |
28 |
Correct |
8 ms |
4924 KB |
Output is correct |
29 |
Correct |
6 ms |
4820 KB |
Output is correct |
30 |
Correct |
9 ms |
4948 KB |
Output is correct |
31 |
Correct |
8 ms |
4948 KB |
Output is correct |
32 |
Correct |
8 ms |
4948 KB |
Output is correct |
33 |
Correct |
9 ms |
4964 KB |
Output is correct |
34 |
Correct |
8 ms |
4920 KB |
Output is correct |
35 |
Correct |
5 ms |
4436 KB |
Output is correct |
36 |
Correct |
5 ms |
4408 KB |
Output is correct |
37 |
Correct |
5 ms |
4436 KB |
Output is correct |
38 |
Correct |
4 ms |
4180 KB |
Output is correct |
39 |
Correct |
4 ms |
4236 KB |
Output is correct |
40 |
Correct |
14 ms |
5328 KB |
Output is correct |
41 |
Correct |
4 ms |
4180 KB |
Output is correct |
42 |
Correct |
12 ms |
5356 KB |
Output is correct |
43 |
Correct |
12 ms |
5384 KB |
Output is correct |
44 |
Correct |
4 ms |
3844 KB |
Output is correct |
45 |
Correct |
259 ms |
25888 KB |
Output is correct |
46 |
Correct |
93 ms |
16920 KB |
Output is correct |
47 |
Correct |
226 ms |
25996 KB |
Output is correct |
48 |
Correct |
197 ms |
25956 KB |
Output is correct |
49 |
Correct |
59 ms |
14344 KB |
Output is correct |
50 |
Correct |
207 ms |
30856 KB |
Output is correct |
51 |
Correct |
208 ms |
25968 KB |
Output is correct |
52 |
Correct |
61 ms |
14376 KB |
Output is correct |
53 |
Correct |
68 ms |
14336 KB |
Output is correct |
54 |
Correct |
20 ms |
7436 KB |
Output is correct |
55 |
Correct |
213 ms |
30916 KB |
Output is correct |
56 |
Correct |
43 ms |
11648 KB |
Output is correct |
57 |
Correct |
58 ms |
14472 KB |
Output is correct |
58 |
Correct |
72 ms |
17164 KB |
Output is correct |
59 |
Correct |
45 ms |
11596 KB |
Output is correct |
60 |
Correct |
36 ms |
11544 KB |
Output is correct |
61 |
Correct |
68 ms |
17228 KB |
Output is correct |
62 |
Correct |
54 ms |
14020 KB |
Output is correct |
63 |
Correct |
123 ms |
18524 KB |
Output is correct |
64 |
Correct |
45 ms |
11648 KB |
Output is correct |
65 |
Correct |
154 ms |
21532 KB |
Output is correct |
66 |
Correct |
60 ms |
14032 KB |
Output is correct |
67 |
Correct |
120 ms |
18512 KB |
Output is correct |
68 |
Correct |
140 ms |
20536 KB |
Output is correct |
69 |
Correct |
145 ms |
21408 KB |
Output is correct |
70 |
Correct |
59 ms |
14032 KB |
Output is correct |
71 |
Correct |
135 ms |
20596 KB |
Output is correct |
72 |
Correct |
117 ms |
17992 KB |
Output is correct |
73 |
Correct |
165 ms |
23232 KB |
Output is correct |
74 |
Correct |
63 ms |
14032 KB |
Output is correct |
75 |
Correct |
52 ms |
11952 KB |
Output is correct |
76 |
Correct |
116 ms |
18012 KB |
Output is correct |
77 |
Correct |
168 ms |
23132 KB |
Output is correct |
78 |
Correct |
75 ms |
13644 KB |
Output is correct |
79 |
Correct |
53 ms |
11932 KB |
Output is correct |
80 |
Correct |
24 ms |
7892 KB |
Output is correct |
81 |
Correct |
80 ms |
13508 KB |
Output is correct |
82 |
Correct |
116 ms |
19564 KB |
Output is correct |
83 |
Correct |
24 ms |
7680 KB |
Output is correct |
84 |
Incorrect |
119 ms |
19524 KB |
Output isn't correct |
85 |
Halted |
0 ms |
0 KB |
- |