#include <bits/stdc++.h>
using namespace std;
//#define int unsigned short
int n,k,d,a;
int ans = 0;
vector<vector<int>> ady;
vector<vector<int>> adyd;
void dfs(int nodo, int sz, vector<int> c){
ans = max(ans,sz);
for(int x:adyd[nodo]) c[x]++;
for(int x:adyd[nodo]){
if(c[x]>=sz) dfs(x,sz+1,c); // todos los nodos "anteriores" están conectados
}
for(int x:adyd[nodo]) c[x]--;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
ady = vector<vector<int>>(n,vector<int>());
adyd = vector<vector<int>>(n,vector<int>());
vector<int> deg(n);
for(int i=0;i<n;i++){
cin >> d;
deg[i] = d;
for(int j=0;j<d;j++){
cin >> a;
ady[i].push_back(a);
}
}
// paso a dirigido
for(int i=0;i<n;i++){
for(int vec:ady[i]){
if(deg[i]<deg[vec] or (deg[i]==deg[vec] and i<vec)) adyd[i].push_back(vec);
}
}
vector<int> c(n,0);
for(int i=0;i<n;i++){
dfs(i, 1, c);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1072 KB |
Output is correct |
4 |
Correct |
6 ms |
860 KB |
Output is correct |
5 |
Correct |
6 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
1120 KB |
Output is correct |
7 |
Correct |
6 ms |
1116 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1072 KB |
Output is correct |
4 |
Correct |
6 ms |
860 KB |
Output is correct |
5 |
Correct |
6 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
1120 KB |
Output is correct |
7 |
Correct |
6 ms |
1116 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
7 ms |
860 KB |
Output is correct |
12 |
Correct |
6 ms |
856 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
6 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
860 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
5 ms |
860 KB |
Output is correct |
21 |
Correct |
5 ms |
860 KB |
Output is correct |
22 |
Correct |
3 ms |
604 KB |
Output is correct |
23 |
Correct |
8 ms |
860 KB |
Output is correct |
24 |
Correct |
3 ms |
604 KB |
Output is correct |
25 |
Correct |
8 ms |
860 KB |
Output is correct |
26 |
Correct |
7 ms |
860 KB |
Output is correct |
27 |
Correct |
7 ms |
860 KB |
Output is correct |
28 |
Correct |
9 ms |
860 KB |
Output is correct |
29 |
Correct |
8 ms |
860 KB |
Output is correct |
30 |
Correct |
9 ms |
856 KB |
Output is correct |
31 |
Correct |
8 ms |
860 KB |
Output is correct |
32 |
Correct |
8 ms |
860 KB |
Output is correct |
33 |
Correct |
8 ms |
856 KB |
Output is correct |
34 |
Correct |
8 ms |
860 KB |
Output is correct |
35 |
Correct |
2 ms |
604 KB |
Output is correct |
36 |
Correct |
2 ms |
604 KB |
Output is correct |
37 |
Correct |
2 ms |
604 KB |
Output is correct |
38 |
Correct |
1 ms |
604 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
10 ms |
956 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
10 ms |
1116 KB |
Output is correct |
43 |
Correct |
10 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
3085 ms |
9896 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1072 KB |
Output is correct |
4 |
Correct |
6 ms |
860 KB |
Output is correct |
5 |
Correct |
6 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
1120 KB |
Output is correct |
7 |
Correct |
6 ms |
1116 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
7 ms |
860 KB |
Output is correct |
12 |
Correct |
6 ms |
856 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
6 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
860 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
5 ms |
860 KB |
Output is correct |
21 |
Correct |
5 ms |
860 KB |
Output is correct |
22 |
Correct |
3 ms |
604 KB |
Output is correct |
23 |
Correct |
8 ms |
860 KB |
Output is correct |
24 |
Correct |
3 ms |
604 KB |
Output is correct |
25 |
Correct |
8 ms |
860 KB |
Output is correct |
26 |
Correct |
7 ms |
860 KB |
Output is correct |
27 |
Correct |
7 ms |
860 KB |
Output is correct |
28 |
Correct |
9 ms |
860 KB |
Output is correct |
29 |
Correct |
8 ms |
860 KB |
Output is correct |
30 |
Correct |
9 ms |
856 KB |
Output is correct |
31 |
Correct |
8 ms |
860 KB |
Output is correct |
32 |
Correct |
8 ms |
860 KB |
Output is correct |
33 |
Correct |
8 ms |
856 KB |
Output is correct |
34 |
Correct |
8 ms |
860 KB |
Output is correct |
35 |
Correct |
2 ms |
604 KB |
Output is correct |
36 |
Correct |
2 ms |
604 KB |
Output is correct |
37 |
Correct |
2 ms |
604 KB |
Output is correct |
38 |
Correct |
1 ms |
604 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
10 ms |
956 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
10 ms |
1116 KB |
Output is correct |
43 |
Correct |
10 ms |
1116 KB |
Output is correct |
44 |
Correct |
219 ms |
1308 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
10 ms |
1112 KB |
Output is correct |
47 |
Correct |
18 ms |
1116 KB |
Output is correct |
48 |
Correct |
10 ms |
1116 KB |
Output is correct |
49 |
Correct |
17 ms |
1116 KB |
Output is correct |
50 |
Correct |
20 ms |
1412 KB |
Output is correct |
51 |
Correct |
37 ms |
1660 KB |
Output is correct |
52 |
Correct |
7 ms |
860 KB |
Output is correct |
53 |
Correct |
31 ms |
1624 KB |
Output is correct |
54 |
Correct |
39 ms |
1784 KB |
Output is correct |
55 |
Correct |
6 ms |
1112 KB |
Output is correct |
56 |
Correct |
7 ms |
1112 KB |
Output is correct |
57 |
Correct |
3 ms |
604 KB |
Output is correct |
58 |
Correct |
31 ms |
1628 KB |
Output is correct |
59 |
Correct |
18 ms |
1116 KB |
Output is correct |
60 |
Correct |
6 ms |
1112 KB |
Output is correct |
61 |
Correct |
19 ms |
1000 KB |
Output is correct |
62 |
Correct |
20 ms |
1116 KB |
Output is correct |
63 |
Correct |
229 ms |
1312 KB |
Output is correct |
64 |
Correct |
130 ms |
1284 KB |
Output is correct |
65 |
Correct |
10 ms |
1116 KB |
Output is correct |
66 |
Correct |
18 ms |
1124 KB |
Output is correct |
67 |
Correct |
78 ms |
1612 KB |
Output is correct |
68 |
Correct |
123 ms |
1292 KB |
Output is correct |
69 |
Correct |
10 ms |
1112 KB |
Output is correct |
70 |
Correct |
20 ms |
1288 KB |
Output is correct |
71 |
Correct |
70 ms |
1436 KB |
Output is correct |
72 |
Correct |
47 ms |
1400 KB |
Output is correct |
73 |
Correct |
7 ms |
860 KB |
Output is correct |
74 |
Correct |
20 ms |
1304 KB |
Output is correct |
75 |
Correct |
52 ms |
1576 KB |
Output is correct |
76 |
Correct |
12 ms |
1116 KB |
Output is correct |
77 |
Correct |
26 ms |
1368 KB |
Output is correct |
78 |
Correct |
10 ms |
856 KB |
Output is correct |
79 |
Correct |
6 ms |
860 KB |
Output is correct |
80 |
Correct |
13 ms |
1116 KB |
Output is correct |
81 |
Correct |
22 ms |
1372 KB |
Output is correct |
82 |
Correct |
1 ms |
604 KB |
Output is correct |
83 |
Correct |
6 ms |
860 KB |
Output is correct |
84 |
Correct |
19 ms |
1376 KB |
Output is correct |
85 |
Correct |
1 ms |
604 KB |
Output is correct |
86 |
Correct |
18 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1072 KB |
Output is correct |
4 |
Correct |
6 ms |
860 KB |
Output is correct |
5 |
Correct |
6 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
1120 KB |
Output is correct |
7 |
Correct |
6 ms |
1116 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
7 ms |
860 KB |
Output is correct |
12 |
Correct |
6 ms |
856 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
6 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
860 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
5 ms |
860 KB |
Output is correct |
21 |
Correct |
5 ms |
860 KB |
Output is correct |
22 |
Correct |
3 ms |
604 KB |
Output is correct |
23 |
Correct |
8 ms |
860 KB |
Output is correct |
24 |
Correct |
3 ms |
604 KB |
Output is correct |
25 |
Correct |
8 ms |
860 KB |
Output is correct |
26 |
Correct |
7 ms |
860 KB |
Output is correct |
27 |
Correct |
7 ms |
860 KB |
Output is correct |
28 |
Correct |
9 ms |
860 KB |
Output is correct |
29 |
Correct |
8 ms |
860 KB |
Output is correct |
30 |
Correct |
9 ms |
856 KB |
Output is correct |
31 |
Correct |
8 ms |
860 KB |
Output is correct |
32 |
Correct |
8 ms |
860 KB |
Output is correct |
33 |
Correct |
8 ms |
856 KB |
Output is correct |
34 |
Correct |
8 ms |
860 KB |
Output is correct |
35 |
Correct |
2 ms |
604 KB |
Output is correct |
36 |
Correct |
2 ms |
604 KB |
Output is correct |
37 |
Correct |
2 ms |
604 KB |
Output is correct |
38 |
Correct |
1 ms |
604 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
10 ms |
956 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
10 ms |
1116 KB |
Output is correct |
43 |
Correct |
10 ms |
1116 KB |
Output is correct |
44 |
Correct |
0 ms |
344 KB |
Output is correct |
45 |
Execution timed out |
3037 ms |
7908 KB |
Time limit exceeded |
46 |
Halted |
0 ms |
0 KB |
- |