# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
997482 | 2024-06-12T11:21:08 Z | ALTAKEXE | 9월 (APIO24_september) | C++17 | 427 ms | 12360 KB |
#include <bits/stdc++.h> #include <vector> using namespace std; vector<vector<int>> adj(100005); vector<bool> vis(100005); vector<int> p(100005); int c = -1; void dfs(int u) { if (vis[u]) return; vis[u] = true; c = max(c, p[u]); for (auto i : adj[u]) dfs(i); } int solve(int n, int m, vector<int> f, vector<vector<int>> s) { for (int i = 1; i < n; i++) adj[f[i]].push_back(i); for (int j = 0; j < m; j++) { for (int i = 0; i < n - 1; i++) p[s[j][i]] = max(p[s[j][i]], i); } int ans = 0; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < m; j++) { if (i > c && j == 0) ans++; dfs(s[j][i]); } } for (int i = 0; i < adj.size(); i++) adj[i].clear(); fill(vis.begin(), vis.end(), 0); fill(p.begin(), p.end(), 0); c = -1; return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3160 KB | Output is correct |
2 | Correct | 2 ms | 3160 KB | Output is correct |
3 | Correct | 3 ms | 3096 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 2 ms | 3212 KB | Output is correct |
6 | Correct | 2 ms | 3164 KB | Output is correct |
7 | Correct | 2 ms | 3164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3160 KB | Output is correct |
2 | Correct | 2 ms | 3160 KB | Output is correct |
3 | Correct | 3 ms | 3096 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 2 ms | 3212 KB | Output is correct |
6 | Correct | 2 ms | 3164 KB | Output is correct |
7 | Correct | 2 ms | 3164 KB | Output is correct |
8 | Correct | 1 ms | 3164 KB | Output is correct |
9 | Correct | 2 ms | 3164 KB | Output is correct |
10 | Correct | 2 ms | 3164 KB | Output is correct |
11 | Correct | 2 ms | 3164 KB | Output is correct |
12 | Correct | 2 ms | 3164 KB | Output is correct |
13 | Correct | 2 ms | 3164 KB | Output is correct |
14 | Correct | 2 ms | 3164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3164 KB | Output is correct |
2 | Correct | 8 ms | 3164 KB | Output is correct |
3 | Correct | 9 ms | 3164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3160 KB | Output is correct |
2 | Correct | 2 ms | 3160 KB | Output is correct |
3 | Correct | 3 ms | 3096 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 2 ms | 3212 KB | Output is correct |
6 | Correct | 2 ms | 3164 KB | Output is correct |
7 | Correct | 2 ms | 3164 KB | Output is correct |
8 | Correct | 9 ms | 3164 KB | Output is correct |
9 | Correct | 8 ms | 3164 KB | Output is correct |
10 | Correct | 9 ms | 3164 KB | Output is correct |
11 | Correct | 8 ms | 3160 KB | Output is correct |
12 | Correct | 8 ms | 3164 KB | Output is correct |
13 | Correct | 10 ms | 3220 KB | Output is correct |
14 | Correct | 9 ms | 3164 KB | Output is correct |
15 | Correct | 9 ms | 3256 KB | Output is correct |
16 | Correct | 11 ms | 3164 KB | Output is correct |
17 | Correct | 9 ms | 3164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3164 KB | Output is correct |
2 | Correct | 8 ms | 3164 KB | Output is correct |
3 | Correct | 9 ms | 3164 KB | Output is correct |
4 | Correct | 9 ms | 3160 KB | Output is correct |
5 | Correct | 13 ms | 3224 KB | Output is correct |
6 | Correct | 9 ms | 3164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3160 KB | Output is correct |
2 | Correct | 2 ms | 3160 KB | Output is correct |
3 | Correct | 3 ms | 3096 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 2 ms | 3212 KB | Output is correct |
6 | Correct | 2 ms | 3164 KB | Output is correct |
7 | Correct | 2 ms | 3164 KB | Output is correct |
8 | Correct | 1 ms | 3164 KB | Output is correct |
9 | Correct | 2 ms | 3164 KB | Output is correct |
10 | Correct | 2 ms | 3164 KB | Output is correct |
11 | Correct | 2 ms | 3164 KB | Output is correct |
12 | Correct | 2 ms | 3164 KB | Output is correct |
13 | Correct | 2 ms | 3164 KB | Output is correct |
14 | Correct | 2 ms | 3164 KB | Output is correct |
15 | Correct | 9 ms | 3164 KB | Output is correct |
16 | Correct | 8 ms | 3164 KB | Output is correct |
17 | Correct | 9 ms | 3164 KB | Output is correct |
18 | Correct | 8 ms | 3160 KB | Output is correct |
19 | Correct | 8 ms | 3164 KB | Output is correct |
20 | Correct | 10 ms | 3220 KB | Output is correct |
21 | Correct | 9 ms | 3164 KB | Output is correct |
22 | Correct | 9 ms | 3256 KB | Output is correct |
23 | Correct | 11 ms | 3164 KB | Output is correct |
24 | Correct | 9 ms | 3164 KB | Output is correct |
25 | Correct | 9 ms | 3160 KB | Output is correct |
26 | Correct | 13 ms | 3224 KB | Output is correct |
27 | Correct | 9 ms | 3164 KB | Output is correct |
28 | Correct | 9 ms | 3160 KB | Output is correct |
29 | Correct | 8 ms | 3160 KB | Output is correct |
30 | Correct | 9 ms | 3164 KB | Output is correct |
31 | Correct | 9 ms | 3164 KB | Output is correct |
32 | Correct | 9 ms | 3164 KB | Output is correct |
33 | Correct | 11 ms | 3164 KB | Output is correct |
34 | Correct | 9 ms | 3164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3164 KB | Output is correct |
2 | Correct | 8 ms | 3164 KB | Output is correct |
3 | Correct | 9 ms | 3164 KB | Output is correct |
4 | Correct | 378 ms | 7880 KB | Output is correct |
5 | Correct | 426 ms | 7884 KB | Output is correct |
6 | Correct | 361 ms | 7880 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3160 KB | Output is correct |
2 | Correct | 2 ms | 3160 KB | Output is correct |
3 | Correct | 3 ms | 3096 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 2 ms | 3212 KB | Output is correct |
6 | Correct | 2 ms | 3164 KB | Output is correct |
7 | Correct | 2 ms | 3164 KB | Output is correct |
8 | Correct | 9 ms | 3164 KB | Output is correct |
9 | Correct | 8 ms | 3164 KB | Output is correct |
10 | Correct | 9 ms | 3164 KB | Output is correct |
11 | Correct | 8 ms | 3160 KB | Output is correct |
12 | Correct | 8 ms | 3164 KB | Output is correct |
13 | Correct | 10 ms | 3220 KB | Output is correct |
14 | Correct | 9 ms | 3164 KB | Output is correct |
15 | Correct | 9 ms | 3256 KB | Output is correct |
16 | Correct | 11 ms | 3164 KB | Output is correct |
17 | Correct | 9 ms | 3164 KB | Output is correct |
18 | Correct | 378 ms | 7880 KB | Output is correct |
19 | Correct | 426 ms | 7884 KB | Output is correct |
20 | Correct | 361 ms | 7880 KB | Output is correct |
21 | Correct | 413 ms | 7356 KB | Output is correct |
22 | Correct | 377 ms | 7348 KB | Output is correct |
23 | Correct | 370 ms | 7864 KB | Output is correct |
24 | Correct | 383 ms | 7680 KB | Output is correct |
25 | Correct | 427 ms | 7404 KB | Output is correct |
26 | Correct | 392 ms | 7412 KB | Output is correct |
27 | Correct | 412 ms | 7680 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3164 KB | Output is correct |
2 | Correct | 8 ms | 3164 KB | Output is correct |
3 | Correct | 9 ms | 3164 KB | Output is correct |
4 | Correct | 9 ms | 3160 KB | Output is correct |
5 | Correct | 13 ms | 3224 KB | Output is correct |
6 | Correct | 9 ms | 3164 KB | Output is correct |
7 | Correct | 378 ms | 7880 KB | Output is correct |
8 | Correct | 426 ms | 7884 KB | Output is correct |
9 | Correct | 361 ms | 7880 KB | Output is correct |
10 | Correct | 113 ms | 11464 KB | Output is correct |
11 | Correct | 112 ms | 11548 KB | Output is correct |
12 | Correct | 116 ms | 12360 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3160 KB | Output is correct |
2 | Correct | 2 ms | 3160 KB | Output is correct |
3 | Correct | 3 ms | 3096 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 2 ms | 3212 KB | Output is correct |
6 | Correct | 2 ms | 3164 KB | Output is correct |
7 | Correct | 2 ms | 3164 KB | Output is correct |
8 | Correct | 1 ms | 3164 KB | Output is correct |
9 | Correct | 2 ms | 3164 KB | Output is correct |
10 | Correct | 2 ms | 3164 KB | Output is correct |
11 | Correct | 2 ms | 3164 KB | Output is correct |
12 | Correct | 2 ms | 3164 KB | Output is correct |
13 | Correct | 2 ms | 3164 KB | Output is correct |
14 | Correct | 2 ms | 3164 KB | Output is correct |
15 | Correct | 9 ms | 3164 KB | Output is correct |
16 | Correct | 8 ms | 3164 KB | Output is correct |
17 | Correct | 9 ms | 3164 KB | Output is correct |
18 | Correct | 8 ms | 3160 KB | Output is correct |
19 | Correct | 8 ms | 3164 KB | Output is correct |
20 | Correct | 10 ms | 3220 KB | Output is correct |
21 | Correct | 9 ms | 3164 KB | Output is correct |
22 | Correct | 9 ms | 3256 KB | Output is correct |
23 | Correct | 11 ms | 3164 KB | Output is correct |
24 | Correct | 9 ms | 3164 KB | Output is correct |
25 | Correct | 9 ms | 3160 KB | Output is correct |
26 | Correct | 13 ms | 3224 KB | Output is correct |
27 | Correct | 9 ms | 3164 KB | Output is correct |
28 | Correct | 9 ms | 3160 KB | Output is correct |
29 | Correct | 8 ms | 3160 KB | Output is correct |
30 | Correct | 9 ms | 3164 KB | Output is correct |
31 | Correct | 9 ms | 3164 KB | Output is correct |
32 | Correct | 9 ms | 3164 KB | Output is correct |
33 | Correct | 11 ms | 3164 KB | Output is correct |
34 | Correct | 9 ms | 3164 KB | Output is correct |
35 | Correct | 378 ms | 7880 KB | Output is correct |
36 | Correct | 426 ms | 7884 KB | Output is correct |
37 | Correct | 361 ms | 7880 KB | Output is correct |
38 | Correct | 413 ms | 7356 KB | Output is correct |
39 | Correct | 377 ms | 7348 KB | Output is correct |
40 | Correct | 370 ms | 7864 KB | Output is correct |
41 | Correct | 383 ms | 7680 KB | Output is correct |
42 | Correct | 427 ms | 7404 KB | Output is correct |
43 | Correct | 392 ms | 7412 KB | Output is correct |
44 | Correct | 412 ms | 7680 KB | Output is correct |
45 | Correct | 113 ms | 11464 KB | Output is correct |
46 | Correct | 112 ms | 11548 KB | Output is correct |
47 | Correct | 116 ms | 12360 KB | Output is correct |
48 | Correct | 115 ms | 11208 KB | Output is correct |
49 | Correct | 115 ms | 10956 KB | Output is correct |
50 | Correct | 113 ms | 10956 KB | Output is correct |
51 | Correct | 113 ms | 11572 KB | Output is correct |
52 | Correct | 118 ms | 11072 KB | Output is correct |
53 | Correct | 150 ms | 10956 KB | Output is correct |
54 | Correct | 137 ms | 11480 KB | Output is correct |