#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]--;
}
int32_t main(){
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1048 KB |
Output is correct |
4 |
Correct |
8 ms |
860 KB |
Output is correct |
5 |
Correct |
8 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
860 KB |
Output is correct |
7 |
Correct |
8 ms |
1112 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1048 KB |
Output is correct |
4 |
Correct |
8 ms |
860 KB |
Output is correct |
5 |
Correct |
8 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
860 KB |
Output is correct |
7 |
Correct |
8 ms |
1112 KB |
Output is correct |
8 |
Correct |
3 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 |
8 ms |
860 KB |
Output is correct |
12 |
Correct |
8 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
8 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
9 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 |
6 ms |
860 KB |
Output is correct |
21 |
Correct |
6 ms |
860 KB |
Output is correct |
22 |
Correct |
3 ms |
604 KB |
Output is correct |
23 |
Correct |
10 ms |
860 KB |
Output is correct |
24 |
Correct |
3 ms |
692 KB |
Output is correct |
25 |
Correct |
10 ms |
860 KB |
Output is correct |
26 |
Correct |
9 ms |
860 KB |
Output is correct |
27 |
Correct |
8 ms |
872 KB |
Output is correct |
28 |
Correct |
9 ms |
872 KB |
Output is correct |
29 |
Correct |
8 ms |
860 KB |
Output is correct |
30 |
Correct |
10 ms |
860 KB |
Output is correct |
31 |
Correct |
10 ms |
1032 KB |
Output is correct |
32 |
Correct |
10 ms |
860 KB |
Output is correct |
33 |
Correct |
10 ms |
1028 KB |
Output is correct |
34 |
Correct |
10 ms |
860 KB |
Output is correct |
35 |
Correct |
3 ms |
604 KB |
Output is correct |
36 |
Correct |
3 ms |
604 KB |
Output is correct |
37 |
Correct |
3 ms |
604 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
14 ms |
1100 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
14 ms |
1024 KB |
Output is correct |
43 |
Correct |
15 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
532 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 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 |
3087 ms |
9704 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1048 KB |
Output is correct |
4 |
Correct |
8 ms |
860 KB |
Output is correct |
5 |
Correct |
8 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
860 KB |
Output is correct |
7 |
Correct |
8 ms |
1112 KB |
Output is correct |
8 |
Correct |
3 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 |
8 ms |
860 KB |
Output is correct |
12 |
Correct |
8 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
8 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
9 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 |
6 ms |
860 KB |
Output is correct |
21 |
Correct |
6 ms |
860 KB |
Output is correct |
22 |
Correct |
3 ms |
604 KB |
Output is correct |
23 |
Correct |
10 ms |
860 KB |
Output is correct |
24 |
Correct |
3 ms |
692 KB |
Output is correct |
25 |
Correct |
10 ms |
860 KB |
Output is correct |
26 |
Correct |
9 ms |
860 KB |
Output is correct |
27 |
Correct |
8 ms |
872 KB |
Output is correct |
28 |
Correct |
9 ms |
872 KB |
Output is correct |
29 |
Correct |
8 ms |
860 KB |
Output is correct |
30 |
Correct |
10 ms |
860 KB |
Output is correct |
31 |
Correct |
10 ms |
1032 KB |
Output is correct |
32 |
Correct |
10 ms |
860 KB |
Output is correct |
33 |
Correct |
10 ms |
1028 KB |
Output is correct |
34 |
Correct |
10 ms |
860 KB |
Output is correct |
35 |
Correct |
3 ms |
604 KB |
Output is correct |
36 |
Correct |
3 ms |
604 KB |
Output is correct |
37 |
Correct |
3 ms |
604 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
14 ms |
1100 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
14 ms |
1024 KB |
Output is correct |
43 |
Correct |
15 ms |
1100 KB |
Output is correct |
44 |
Correct |
229 ms |
1284 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
13 ms |
1224 KB |
Output is correct |
47 |
Correct |
22 ms |
1372 KB |
Output is correct |
48 |
Correct |
13 ms |
1116 KB |
Output is correct |
49 |
Correct |
22 ms |
1372 KB |
Output is correct |
50 |
Correct |
22 ms |
1372 KB |
Output is correct |
51 |
Correct |
42 ms |
2012 KB |
Output is correct |
52 |
Correct |
8 ms |
1116 KB |
Output is correct |
53 |
Correct |
41 ms |
2080 KB |
Output is correct |
54 |
Correct |
48 ms |
2228 KB |
Output is correct |
55 |
Correct |
8 ms |
1316 KB |
Output is correct |
56 |
Correct |
8 ms |
1116 KB |
Output is correct |
57 |
Correct |
4 ms |
604 KB |
Output is correct |
58 |
Correct |
42 ms |
1996 KB |
Output is correct |
59 |
Correct |
21 ms |
1192 KB |
Output is correct |
60 |
Correct |
8 ms |
1116 KB |
Output is correct |
61 |
Correct |
21 ms |
1124 KB |
Output is correct |
62 |
Correct |
21 ms |
1116 KB |
Output is correct |
63 |
Correct |
223 ms |
1668 KB |
Output is correct |
64 |
Correct |
144 ms |
1436 KB |
Output is correct |
65 |
Correct |
13 ms |
1116 KB |
Output is correct |
66 |
Correct |
20 ms |
1116 KB |
Output is correct |
67 |
Correct |
77 ms |
1652 KB |
Output is correct |
68 |
Correct |
125 ms |
1436 KB |
Output is correct |
69 |
Correct |
12 ms |
1176 KB |
Output is correct |
70 |
Correct |
24 ms |
1448 KB |
Output is correct |
71 |
Correct |
76 ms |
1648 KB |
Output is correct |
72 |
Correct |
54 ms |
1732 KB |
Output is correct |
73 |
Correct |
8 ms |
860 KB |
Output is correct |
74 |
Correct |
25 ms |
1372 KB |
Output is correct |
75 |
Correct |
52 ms |
1608 KB |
Output is correct |
76 |
Correct |
16 ms |
1112 KB |
Output is correct |
77 |
Correct |
29 ms |
1660 KB |
Output is correct |
78 |
Correct |
8 ms |
860 KB |
Output is correct |
79 |
Correct |
11 ms |
1116 KB |
Output is correct |
80 |
Correct |
16 ms |
1116 KB |
Output is correct |
81 |
Correct |
29 ms |
1628 KB |
Output is correct |
82 |
Correct |
2 ms |
604 KB |
Output is correct |
83 |
Correct |
10 ms |
820 KB |
Output is correct |
84 |
Correct |
24 ms |
1628 KB |
Output is correct |
85 |
Correct |
2 ms |
604 KB |
Output is correct |
86 |
Correct |
24 ms |
1636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
1048 KB |
Output is correct |
4 |
Correct |
8 ms |
860 KB |
Output is correct |
5 |
Correct |
8 ms |
860 KB |
Output is correct |
6 |
Correct |
8 ms |
860 KB |
Output is correct |
7 |
Correct |
8 ms |
1112 KB |
Output is correct |
8 |
Correct |
3 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 |
8 ms |
860 KB |
Output is correct |
12 |
Correct |
8 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
8 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
9 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 |
6 ms |
860 KB |
Output is correct |
21 |
Correct |
6 ms |
860 KB |
Output is correct |
22 |
Correct |
3 ms |
604 KB |
Output is correct |
23 |
Correct |
10 ms |
860 KB |
Output is correct |
24 |
Correct |
3 ms |
692 KB |
Output is correct |
25 |
Correct |
10 ms |
860 KB |
Output is correct |
26 |
Correct |
9 ms |
860 KB |
Output is correct |
27 |
Correct |
8 ms |
872 KB |
Output is correct |
28 |
Correct |
9 ms |
872 KB |
Output is correct |
29 |
Correct |
8 ms |
860 KB |
Output is correct |
30 |
Correct |
10 ms |
860 KB |
Output is correct |
31 |
Correct |
10 ms |
1032 KB |
Output is correct |
32 |
Correct |
10 ms |
860 KB |
Output is correct |
33 |
Correct |
10 ms |
1028 KB |
Output is correct |
34 |
Correct |
10 ms |
860 KB |
Output is correct |
35 |
Correct |
3 ms |
604 KB |
Output is correct |
36 |
Correct |
3 ms |
604 KB |
Output is correct |
37 |
Correct |
3 ms |
604 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
14 ms |
1100 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
14 ms |
1024 KB |
Output is correct |
43 |
Correct |
15 ms |
1100 KB |
Output is correct |
44 |
Correct |
0 ms |
344 KB |
Output is correct |
45 |
Execution timed out |
3026 ms |
8116 KB |
Time limit exceeded |
46 |
Halted |
0 ms |
0 KB |
- |