#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(v) begin(v), end(v)
int main() {
int n, k; cin >> n >> k;
assert(k <= 3);
vector<vector<int>> g(n);
{
bool f = false;
rep (i, n) {
int d; cin >> d;
if (d) f = true;
rep (j, d) {
int a; cin >> a;
g[i].push_back(a);
}
}
if (!f) {
puts("1");
return 0;
}
}
rep (i, n) {
vector<bool> memo(n, false);
for (auto j : g[i]) memo[j] = true;
for (auto j : g[i]) {
for (auto k : g[j]) {
if (k == i) continue;
if (memo[k]) {
puts("3");
return 0;
}
}
}
}
puts("2");
}
# |
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 |
3 ms |
556 KB |
Output is correct |
4 |
Correct |
25 ms |
604 KB |
Output is correct |
5 |
Correct |
23 ms |
600 KB |
Output is correct |
6 |
Correct |
4 ms |
604 KB |
Output is correct |
7 |
Correct |
3 ms |
604 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 |
552 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 |
3 ms |
556 KB |
Output is correct |
4 |
Correct |
25 ms |
604 KB |
Output is correct |
5 |
Correct |
23 ms |
600 KB |
Output is correct |
6 |
Correct |
4 ms |
604 KB |
Output is correct |
7 |
Correct |
3 ms |
604 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 |
552 KB |
Output is correct |
11 |
Correct |
23 ms |
604 KB |
Output is correct |
12 |
Correct |
23 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
23 ms |
740 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
568 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
664 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
4 ms |
704 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
6 ms |
716 KB |
Output is correct |
26 |
Correct |
4 ms |
772 KB |
Output is correct |
27 |
Correct |
3 ms |
600 KB |
Output is correct |
28 |
Correct |
4 ms |
704 KB |
Output is correct |
29 |
Correct |
3 ms |
604 KB |
Output is correct |
30 |
Correct |
9 ms |
604 KB |
Output is correct |
31 |
Correct |
4 ms |
720 KB |
Output is correct |
32 |
Correct |
12 ms |
604 KB |
Output is correct |
33 |
Correct |
7 ms |
604 KB |
Output is correct |
34 |
Correct |
7 ms |
732 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 |
448 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
344 KB |
Output is correct |
40 |
Correct |
5 ms |
604 KB |
Output is correct |
41 |
Correct |
3 ms |
348 KB |
Output is correct |
42 |
Correct |
8 ms |
604 KB |
Output is correct |
43 |
Correct |
5 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 6 |
2 |
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 |
3 ms |
556 KB |
Output is correct |
4 |
Correct |
25 ms |
604 KB |
Output is correct |
5 |
Correct |
23 ms |
600 KB |
Output is correct |
6 |
Correct |
4 ms |
604 KB |
Output is correct |
7 |
Correct |
3 ms |
604 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 |
552 KB |
Output is correct |
11 |
Correct |
23 ms |
604 KB |
Output is correct |
12 |
Correct |
23 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
23 ms |
740 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
568 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
664 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
4 ms |
704 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
6 ms |
716 KB |
Output is correct |
26 |
Correct |
4 ms |
772 KB |
Output is correct |
27 |
Correct |
3 ms |
600 KB |
Output is correct |
28 |
Correct |
4 ms |
704 KB |
Output is correct |
29 |
Correct |
3 ms |
604 KB |
Output is correct |
30 |
Correct |
9 ms |
604 KB |
Output is correct |
31 |
Correct |
4 ms |
720 KB |
Output is correct |
32 |
Correct |
12 ms |
604 KB |
Output is correct |
33 |
Correct |
7 ms |
604 KB |
Output is correct |
34 |
Correct |
7 ms |
732 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 |
448 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
344 KB |
Output is correct |
40 |
Correct |
5 ms |
604 KB |
Output is correct |
41 |
Correct |
3 ms |
348 KB |
Output is correct |
42 |
Correct |
8 ms |
604 KB |
Output is correct |
43 |
Correct |
5 ms |
604 KB |
Output is correct |
44 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
45 |
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 |
3 ms |
556 KB |
Output is correct |
4 |
Correct |
25 ms |
604 KB |
Output is correct |
5 |
Correct |
23 ms |
600 KB |
Output is correct |
6 |
Correct |
4 ms |
604 KB |
Output is correct |
7 |
Correct |
3 ms |
604 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 |
552 KB |
Output is correct |
11 |
Correct |
23 ms |
604 KB |
Output is correct |
12 |
Correct |
23 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
23 ms |
740 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
568 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
664 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
4 ms |
704 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
6 ms |
716 KB |
Output is correct |
26 |
Correct |
4 ms |
772 KB |
Output is correct |
27 |
Correct |
3 ms |
600 KB |
Output is correct |
28 |
Correct |
4 ms |
704 KB |
Output is correct |
29 |
Correct |
3 ms |
604 KB |
Output is correct |
30 |
Correct |
9 ms |
604 KB |
Output is correct |
31 |
Correct |
4 ms |
720 KB |
Output is correct |
32 |
Correct |
12 ms |
604 KB |
Output is correct |
33 |
Correct |
7 ms |
604 KB |
Output is correct |
34 |
Correct |
7 ms |
732 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 |
448 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
344 KB |
Output is correct |
40 |
Correct |
5 ms |
604 KB |
Output is correct |
41 |
Correct |
3 ms |
348 KB |
Output is correct |
42 |
Correct |
8 ms |
604 KB |
Output is correct |
43 |
Correct |
5 ms |
604 KB |
Output is correct |
44 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
45 |
Halted |
0 ms |
0 KB |
- |