#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e4 + 12, MOD = (int)1e9 + 7;
int n, k, timer = 0;
vector<int> g[N], vis[N];
map<vector<int>,int> mem;
int calc(vector<int> &x, int tim) {
if(x.empty()) return 0;
if(mem.count(x)) return mem[x];
for(int i:x) {
vis[i].push_back(tim);
}
int ret = 0;
for(int i:x) {
vector<int> nv;
for(int to:g[i]) {
if(!vis[to].empty() && vis[to].back() == tim) {
nv.push_back(to);
}
}
ret = max(ret,1 + calc(nv, tim + 1));
}
for(int i:x) {
vis[i].pop_back();
}
return mem[x] = ret;
}
void test() {
cin >> n >> k;
for(int i = 1; i <= n; i++) {
int d;
cin >> d;
for(int j = 0; j < d; j++) {
int x;
cin >> x;
++x;
g[x].push_back(i);
// cout << x << ' ' << d << '\n';
}
}
int res = 0;
for(int i = 1; i <= n; i++) {
res = max(res, 1 + calc(g[i], 1));
}
cout << res << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
5 ms |
3420 KB |
Output is correct |
4 |
Correct |
2 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
3 ms |
3044 KB |
Output is correct |
7 |
Correct |
3 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
5 ms |
3420 KB |
Output is correct |
4 |
Correct |
2 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
3 ms |
3044 KB |
Output is correct |
7 |
Correct |
3 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
3 ms |
3160 KB |
Output is correct |
12 |
Correct |
3 ms |
3160 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
2 ms |
3076 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
3 ms |
3164 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
3 ms |
3164 KB |
Output is correct |
19 |
Correct |
1 ms |
2820 KB |
Output is correct |
20 |
Correct |
5 ms |
3676 KB |
Output is correct |
21 |
Correct |
4 ms |
3676 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
5 ms |
3668 KB |
Output is correct |
24 |
Correct |
2 ms |
2652 KB |
Output is correct |
25 |
Correct |
6 ms |
3712 KB |
Output is correct |
26 |
Correct |
5 ms |
3692 KB |
Output is correct |
27 |
Correct |
6 ms |
3676 KB |
Output is correct |
28 |
Correct |
5 ms |
3672 KB |
Output is correct |
29 |
Correct |
4 ms |
3676 KB |
Output is correct |
30 |
Correct |
8 ms |
3580 KB |
Output is correct |
31 |
Correct |
6 ms |
3672 KB |
Output is correct |
32 |
Correct |
8 ms |
3420 KB |
Output is correct |
33 |
Correct |
5 ms |
3672 KB |
Output is correct |
34 |
Correct |
6 ms |
3588 KB |
Output is correct |
35 |
Correct |
3 ms |
3164 KB |
Output is correct |
36 |
Correct |
3 ms |
3080 KB |
Output is correct |
37 |
Correct |
3 ms |
3052 KB |
Output is correct |
38 |
Correct |
2 ms |
2904 KB |
Output is correct |
39 |
Correct |
3 ms |
2908 KB |
Output is correct |
40 |
Correct |
6 ms |
3676 KB |
Output is correct |
41 |
Correct |
3 ms |
2908 KB |
Output is correct |
42 |
Correct |
10 ms |
3608 KB |
Output is correct |
43 |
Correct |
6 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2808 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
124 ms |
16212 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
121 ms |
16424 KB |
Output is correct |
14 |
Correct |
2 ms |
2652 KB |
Output is correct |
15 |
Correct |
122 ms |
16136 KB |
Output is correct |
16 |
Correct |
116 ms |
16208 KB |
Output is correct |
17 |
Correct |
113 ms |
16280 KB |
Output is correct |
18 |
Correct |
109 ms |
16208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
5 ms |
3420 KB |
Output is correct |
4 |
Correct |
2 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
3 ms |
3044 KB |
Output is correct |
7 |
Correct |
3 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
3 ms |
3160 KB |
Output is correct |
12 |
Correct |
3 ms |
3160 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
2 ms |
3076 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
3 ms |
3164 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
3 ms |
3164 KB |
Output is correct |
19 |
Correct |
1 ms |
2820 KB |
Output is correct |
20 |
Correct |
5 ms |
3676 KB |
Output is correct |
21 |
Correct |
4 ms |
3676 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
5 ms |
3668 KB |
Output is correct |
24 |
Correct |
2 ms |
2652 KB |
Output is correct |
25 |
Correct |
6 ms |
3712 KB |
Output is correct |
26 |
Correct |
5 ms |
3692 KB |
Output is correct |
27 |
Correct |
6 ms |
3676 KB |
Output is correct |
28 |
Correct |
5 ms |
3672 KB |
Output is correct |
29 |
Correct |
4 ms |
3676 KB |
Output is correct |
30 |
Correct |
8 ms |
3580 KB |
Output is correct |
31 |
Correct |
6 ms |
3672 KB |
Output is correct |
32 |
Correct |
8 ms |
3420 KB |
Output is correct |
33 |
Correct |
5 ms |
3672 KB |
Output is correct |
34 |
Correct |
6 ms |
3588 KB |
Output is correct |
35 |
Correct |
3 ms |
3164 KB |
Output is correct |
36 |
Correct |
3 ms |
3080 KB |
Output is correct |
37 |
Correct |
3 ms |
3052 KB |
Output is correct |
38 |
Correct |
2 ms |
2904 KB |
Output is correct |
39 |
Correct |
3 ms |
2908 KB |
Output is correct |
40 |
Correct |
6 ms |
3676 KB |
Output is correct |
41 |
Correct |
3 ms |
2908 KB |
Output is correct |
42 |
Correct |
10 ms |
3608 KB |
Output is correct |
43 |
Correct |
6 ms |
3676 KB |
Output is correct |
44 |
Correct |
427 ms |
34796 KB |
Output is correct |
45 |
Correct |
2 ms |
2648 KB |
Output is correct |
46 |
Correct |
7 ms |
3676 KB |
Output is correct |
47 |
Correct |
10 ms |
3932 KB |
Output is correct |
48 |
Correct |
7 ms |
3676 KB |
Output is correct |
49 |
Correct |
16 ms |
4080 KB |
Output is correct |
50 |
Correct |
9 ms |
3932 KB |
Output is correct |
51 |
Correct |
23 ms |
5024 KB |
Output is correct |
52 |
Correct |
2 ms |
3164 KB |
Output is correct |
53 |
Correct |
8 ms |
4096 KB |
Output is correct |
54 |
Correct |
31 ms |
5364 KB |
Output is correct |
55 |
Correct |
3 ms |
3160 KB |
Output is correct |
56 |
Correct |
2 ms |
3164 KB |
Output is correct |
57 |
Correct |
1 ms |
2652 KB |
Output is correct |
58 |
Correct |
9 ms |
3932 KB |
Output is correct |
59 |
Correct |
26 ms |
6492 KB |
Output is correct |
60 |
Correct |
3 ms |
3164 KB |
Output is correct |
61 |
Correct |
26 ms |
6352 KB |
Output is correct |
62 |
Correct |
26 ms |
6348 KB |
Output is correct |
63 |
Correct |
419 ms |
34712 KB |
Output is correct |
64 |
Correct |
203 ms |
20816 KB |
Output is correct |
65 |
Correct |
6 ms |
3672 KB |
Output is correct |
66 |
Correct |
27 ms |
6484 KB |
Output is correct |
67 |
Correct |
140 ms |
11860 KB |
Output is correct |
68 |
Correct |
205 ms |
20820 KB |
Output is correct |
69 |
Correct |
7 ms |
3676 KB |
Output is correct |
70 |
Correct |
23 ms |
5240 KB |
Output is correct |
71 |
Correct |
130 ms |
11856 KB |
Output is correct |
72 |
Correct |
70 ms |
8276 KB |
Output is correct |
73 |
Correct |
5 ms |
3676 KB |
Output is correct |
74 |
Correct |
23 ms |
5292 KB |
Output is correct |
75 |
Correct |
69 ms |
8284 KB |
Output is correct |
76 |
Correct |
13 ms |
3800 KB |
Output is correct |
77 |
Correct |
11 ms |
4188 KB |
Output is correct |
78 |
Correct |
4 ms |
3676 KB |
Output is correct |
79 |
Correct |
7 ms |
3420 KB |
Output is correct |
80 |
Correct |
11 ms |
3676 KB |
Output is correct |
81 |
Correct |
12 ms |
4108 KB |
Output is correct |
82 |
Correct |
2 ms |
2816 KB |
Output is correct |
83 |
Correct |
6 ms |
3416 KB |
Output is correct |
84 |
Correct |
10 ms |
4148 KB |
Output is correct |
85 |
Correct |
2 ms |
2908 KB |
Output is correct |
86 |
Correct |
11 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
5 ms |
3420 KB |
Output is correct |
4 |
Correct |
2 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
3 ms |
3044 KB |
Output is correct |
7 |
Correct |
3 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
3 ms |
3160 KB |
Output is correct |
12 |
Correct |
3 ms |
3160 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
2 ms |
3076 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
3 ms |
3164 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
3 ms |
3164 KB |
Output is correct |
19 |
Correct |
1 ms |
2820 KB |
Output is correct |
20 |
Correct |
5 ms |
3676 KB |
Output is correct |
21 |
Correct |
4 ms |
3676 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
5 ms |
3668 KB |
Output is correct |
24 |
Correct |
2 ms |
2652 KB |
Output is correct |
25 |
Correct |
6 ms |
3712 KB |
Output is correct |
26 |
Correct |
5 ms |
3692 KB |
Output is correct |
27 |
Correct |
6 ms |
3676 KB |
Output is correct |
28 |
Correct |
5 ms |
3672 KB |
Output is correct |
29 |
Correct |
4 ms |
3676 KB |
Output is correct |
30 |
Correct |
8 ms |
3580 KB |
Output is correct |
31 |
Correct |
6 ms |
3672 KB |
Output is correct |
32 |
Correct |
8 ms |
3420 KB |
Output is correct |
33 |
Correct |
5 ms |
3672 KB |
Output is correct |
34 |
Correct |
6 ms |
3588 KB |
Output is correct |
35 |
Correct |
3 ms |
3164 KB |
Output is correct |
36 |
Correct |
3 ms |
3080 KB |
Output is correct |
37 |
Correct |
3 ms |
3052 KB |
Output is correct |
38 |
Correct |
2 ms |
2904 KB |
Output is correct |
39 |
Correct |
3 ms |
2908 KB |
Output is correct |
40 |
Correct |
6 ms |
3676 KB |
Output is correct |
41 |
Correct |
3 ms |
2908 KB |
Output is correct |
42 |
Correct |
10 ms |
3608 KB |
Output is correct |
43 |
Correct |
6 ms |
3676 KB |
Output is correct |
44 |
Correct |
1 ms |
2648 KB |
Output is correct |
45 |
Correct |
92 ms |
13724 KB |
Output is correct |
46 |
Correct |
726 ms |
14872 KB |
Output is correct |
47 |
Correct |
87 ms |
13840 KB |
Output is correct |
48 |
Correct |
86 ms |
13904 KB |
Output is correct |
49 |
Correct |
14 ms |
6748 KB |
Output is correct |
50 |
Correct |
38 ms |
8524 KB |
Output is correct |
51 |
Correct |
87 ms |
14416 KB |
Output is correct |
52 |
Correct |
18 ms |
7000 KB |
Output is correct |
53 |
Correct |
15 ms |
7012 KB |
Output is correct |
54 |
Correct |
4 ms |
2652 KB |
Output is correct |
55 |
Correct |
34 ms |
9224 KB |
Output is correct |
56 |
Correct |
36 ms |
11612 KB |
Output is correct |
57 |
Correct |
20 ms |
7000 KB |
Output is correct |
58 |
Correct |
186 ms |
25940 KB |
Output is correct |
59 |
Correct |
34 ms |
11600 KB |
Output is correct |
60 |
Correct |
46 ms |
11652 KB |
Output is correct |
61 |
Correct |
184 ms |
25936 KB |
Output is correct |
62 |
Correct |
93 ms |
17420 KB |
Output is correct |
63 |
Correct |
75 ms |
13648 KB |
Output is correct |
64 |
Correct |
35 ms |
11612 KB |
Output is correct |
65 |
Correct |
110 ms |
16636 KB |
Output is correct |
66 |
Correct |
94 ms |
17744 KB |
Output is correct |
67 |
Correct |
75 ms |
13652 KB |
Output is correct |
68 |
Correct |
82 ms |
14416 KB |
Output is correct |
69 |
Correct |
106 ms |
16468 KB |
Output is correct |
70 |
Correct |
44 ms |
11856 KB |
Output is correct |
71 |
Correct |
83 ms |
14420 KB |
Output is correct |
72 |
Correct |
672 ms |
11600 KB |
Output is correct |
73 |
Correct |
76 ms |
13652 KB |
Output is correct |
74 |
Correct |
47 ms |
11952 KB |
Output is correct |
75 |
Correct |
31 ms |
7760 KB |
Output is correct |
76 |
Correct |
647 ms |
11692 KB |
Output is correct |
77 |
Correct |
75 ms |
13648 KB |
Output is correct |
78 |
Correct |
33 ms |
8016 KB |
Output is correct |
79 |
Correct |
29 ms |
7764 KB |
Output is correct |
80 |
Correct |
17 ms |
5212 KB |
Output is correct |
81 |
Correct |
38 ms |
8276 KB |
Output is correct |
82 |
Correct |
61 ms |
12624 KB |
Output is correct |
83 |
Correct |
16 ms |
5212 KB |
Output is correct |
84 |
Correct |
59 ms |
12444 KB |
Output is correct |