#include <bits/stdc++.h>
using namespace std;
int main() {
int n, useless;
cin >> n >> useless;
vector<vector<int>> adj(n + 1);
set<pair<int, int>> pr;
for(int i = 1; i <= n; i++) {
int x;
cin >> x;
while(x--) {
int a;
cin >> a;
a++;
adj[i].push_back(a);
pr.insert({min(a, i), max(a, i)});
}
}
vector<vector<vector<int>>> v(n + 1);
for(int i = 1; i <= n; i++) {
v[i].push_back({i});
}
int ans = 0;
while(true) {
vector<vector<vector<int>>> curr(n + 1);
ans++;
bool ok = 0;
for(int i = 1; i <= n; i++) {
// cout << "la " << i << "\n";
for(auto it : adj[i]) {
// cout << "vecin " << it << ':';
vector<int> cp;
bool used = 0;
for(auto s : v[it]) {
bool nf = 0;
for(auto j : s) {
if(pr.find({min(i, j), max(i, j)}) == pr.end()) {
nf = 1;
break;
}
}
if(!nf) {
// cout << " merge, face: ";
cp = s;
used = 1;
ok = 1;
break;
}
}
if(used) {
cp.push_back(i);
curr[i].push_back(cp);
}
}
}
if(!ok) {
break;
}
swap(v, curr); // o(1) plsplspls
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
2140 KB |
Output is correct |
4 |
Correct |
1202 ms |
2140 KB |
Output is correct |
5 |
Correct |
1202 ms |
2140 KB |
Output is correct |
6 |
Correct |
31 ms |
2140 KB |
Output is correct |
7 |
Correct |
30 ms |
2136 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
2140 KB |
Output is correct |
4 |
Correct |
1202 ms |
2140 KB |
Output is correct |
5 |
Correct |
1202 ms |
2140 KB |
Output is correct |
6 |
Correct |
31 ms |
2140 KB |
Output is correct |
7 |
Correct |
30 ms |
2136 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
984 ms |
2140 KB |
Output is correct |
12 |
Correct |
1081 ms |
2136 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1582 ms |
2032 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
35 ms |
2272 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
32 ms |
2112 KB |
Output is correct |
19 |
Correct |
2 ms |
856 KB |
Output is correct |
20 |
Correct |
5 ms |
1624 KB |
Output is correct |
21 |
Correct |
6 ms |
1628 KB |
Output is correct |
22 |
Correct |
2 ms |
860 KB |
Output is correct |
23 |
Correct |
14 ms |
2312 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
16 ms |
2396 KB |
Output is correct |
26 |
Correct |
11 ms |
2140 KB |
Output is correct |
27 |
Correct |
9 ms |
2136 KB |
Output is correct |
28 |
Correct |
12 ms |
2136 KB |
Output is correct |
29 |
Correct |
9 ms |
1988 KB |
Output is correct |
30 |
Correct |
382 ms |
2644 KB |
Output is correct |
31 |
Correct |
13 ms |
2396 KB |
Output is correct |
32 |
Correct |
359 ms |
2464 KB |
Output is correct |
33 |
Correct |
13 ms |
2396 KB |
Output is correct |
34 |
Correct |
13 ms |
2396 KB |
Output is correct |
35 |
Correct |
6 ms |
1372 KB |
Output is correct |
36 |
Correct |
6 ms |
1372 KB |
Output is correct |
37 |
Correct |
7 ms |
1372 KB |
Output is correct |
38 |
Correct |
8 ms |
1088 KB |
Output is correct |
39 |
Correct |
8 ms |
860 KB |
Output is correct |
40 |
Correct |
34 ms |
2908 KB |
Output is correct |
41 |
Correct |
8 ms |
860 KB |
Output is correct |
42 |
Correct |
24 ms |
2908 KB |
Output is correct |
43 |
Correct |
24 ms |
2904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
400 KB |
Output is correct |
11 |
Correct |
1313 ms |
57844 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1318 ms |
57676 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1273 ms |
57780 KB |
Output is correct |
16 |
Correct |
1354 ms |
58092 KB |
Output is correct |
17 |
Correct |
1270 ms |
57684 KB |
Output is correct |
18 |
Correct |
1309 ms |
57844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
2140 KB |
Output is correct |
4 |
Correct |
1202 ms |
2140 KB |
Output is correct |
5 |
Correct |
1202 ms |
2140 KB |
Output is correct |
6 |
Correct |
31 ms |
2140 KB |
Output is correct |
7 |
Correct |
30 ms |
2136 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
984 ms |
2140 KB |
Output is correct |
12 |
Correct |
1081 ms |
2136 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1582 ms |
2032 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
35 ms |
2272 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
32 ms |
2112 KB |
Output is correct |
19 |
Correct |
2 ms |
856 KB |
Output is correct |
20 |
Correct |
5 ms |
1624 KB |
Output is correct |
21 |
Correct |
6 ms |
1628 KB |
Output is correct |
22 |
Correct |
2 ms |
860 KB |
Output is correct |
23 |
Correct |
14 ms |
2312 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
16 ms |
2396 KB |
Output is correct |
26 |
Correct |
11 ms |
2140 KB |
Output is correct |
27 |
Correct |
9 ms |
2136 KB |
Output is correct |
28 |
Correct |
12 ms |
2136 KB |
Output is correct |
29 |
Correct |
9 ms |
1988 KB |
Output is correct |
30 |
Correct |
382 ms |
2644 KB |
Output is correct |
31 |
Correct |
13 ms |
2396 KB |
Output is correct |
32 |
Correct |
359 ms |
2464 KB |
Output is correct |
33 |
Correct |
13 ms |
2396 KB |
Output is correct |
34 |
Correct |
13 ms |
2396 KB |
Output is correct |
35 |
Correct |
6 ms |
1372 KB |
Output is correct |
36 |
Correct |
6 ms |
1372 KB |
Output is correct |
37 |
Correct |
7 ms |
1372 KB |
Output is correct |
38 |
Correct |
8 ms |
1088 KB |
Output is correct |
39 |
Correct |
8 ms |
860 KB |
Output is correct |
40 |
Correct |
34 ms |
2908 KB |
Output is correct |
41 |
Correct |
8 ms |
860 KB |
Output is correct |
42 |
Correct |
24 ms |
2908 KB |
Output is correct |
43 |
Correct |
24 ms |
2904 KB |
Output is correct |
44 |
Correct |
140 ms |
6480 KB |
Output is correct |
45 |
Correct |
1 ms |
344 KB |
Output is correct |
46 |
Correct |
24 ms |
2908 KB |
Output is correct |
47 |
Correct |
67 ms |
4944 KB |
Output is correct |
48 |
Correct |
24 ms |
2904 KB |
Output is correct |
49 |
Correct |
66 ms |
5104 KB |
Output is correct |
50 |
Correct |
68 ms |
5036 KB |
Output is correct |
51 |
Correct |
237 ms |
9320 KB |
Output is correct |
52 |
Correct |
766 ms |
2140 KB |
Output is correct |
53 |
Execution timed out |
3051 ms |
10068 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
10 ms |
2140 KB |
Output is correct |
4 |
Correct |
1202 ms |
2140 KB |
Output is correct |
5 |
Correct |
1202 ms |
2140 KB |
Output is correct |
6 |
Correct |
31 ms |
2140 KB |
Output is correct |
7 |
Correct |
30 ms |
2136 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
984 ms |
2140 KB |
Output is correct |
12 |
Correct |
1081 ms |
2136 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1582 ms |
2032 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
35 ms |
2272 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
32 ms |
2112 KB |
Output is correct |
19 |
Correct |
2 ms |
856 KB |
Output is correct |
20 |
Correct |
5 ms |
1624 KB |
Output is correct |
21 |
Correct |
6 ms |
1628 KB |
Output is correct |
22 |
Correct |
2 ms |
860 KB |
Output is correct |
23 |
Correct |
14 ms |
2312 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
16 ms |
2396 KB |
Output is correct |
26 |
Correct |
11 ms |
2140 KB |
Output is correct |
27 |
Correct |
9 ms |
2136 KB |
Output is correct |
28 |
Correct |
12 ms |
2136 KB |
Output is correct |
29 |
Correct |
9 ms |
1988 KB |
Output is correct |
30 |
Correct |
382 ms |
2644 KB |
Output is correct |
31 |
Correct |
13 ms |
2396 KB |
Output is correct |
32 |
Correct |
359 ms |
2464 KB |
Output is correct |
33 |
Correct |
13 ms |
2396 KB |
Output is correct |
34 |
Correct |
13 ms |
2396 KB |
Output is correct |
35 |
Correct |
6 ms |
1372 KB |
Output is correct |
36 |
Correct |
6 ms |
1372 KB |
Output is correct |
37 |
Correct |
7 ms |
1372 KB |
Output is correct |
38 |
Correct |
8 ms |
1088 KB |
Output is correct |
39 |
Correct |
8 ms |
860 KB |
Output is correct |
40 |
Correct |
34 ms |
2908 KB |
Output is correct |
41 |
Correct |
8 ms |
860 KB |
Output is correct |
42 |
Correct |
24 ms |
2908 KB |
Output is correct |
43 |
Correct |
24 ms |
2904 KB |
Output is correct |
44 |
Correct |
1 ms |
344 KB |
Output is correct |
45 |
Correct |
703 ms |
37720 KB |
Output is correct |
46 |
Execution timed out |
3063 ms |
22796 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |