답안 #1089721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089721 2024-09-17T03:01:50 Z Error_Yuan 9월 (APIO24_september) C++17
100 / 100
103 ms 10228 KB
#include "september.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;

int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
	vector<int> D(N);
	vector<int> vis(N), cur;
	for (int i = 1; i < N; i++) D[F[i]]++;
	int k = 0, cnt = 0, del = 0;
	for (int i = 0; i < N - 1; i++) {
		cnt++;
		for (int j = 0; j < M; j++) {
			vis[S[j][i]]++;
			if (vis[S[j][i]] == 1) {
				cur.push_back(S[j][i]);
				int now = S[j][i];
				while (now != -1 && D[now] == 0 && vis[now] >= 1) {
					D[F[now]]--;
					del++;
					now = F[now];
				}
			}
		}
		if ((int)cur.size() != cnt || cnt != del) continue;
		k++;
		cnt = del = 0;
		for (auto x : cur) vis[x] = 0;
		cur.clear();
	}
	return k;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 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 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 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 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 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 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 532 KB Output is correct
5 Correct 1 ms 532 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 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 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 532 KB Output is correct
26 Correct 1 ms 532 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 91 ms 9624 KB Output is correct
5 Correct 103 ms 9620 KB Output is correct
6 Correct 92 ms 9640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 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 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 91 ms 9624 KB Output is correct
19 Correct 103 ms 9620 KB Output is correct
20 Correct 92 ms 9640 KB Output is correct
21 Correct 99 ms 9632 KB Output is correct
22 Correct 99 ms 9636 KB Output is correct
23 Correct 92 ms 9796 KB Output is correct
24 Correct 95 ms 9772 KB Output is correct
25 Correct 96 ms 9636 KB Output is correct
26 Correct 95 ms 9636 KB Output is correct
27 Correct 94 ms 9640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 532 KB Output is correct
5 Correct 1 ms 532 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 91 ms 9624 KB Output is correct
8 Correct 103 ms 9620 KB Output is correct
9 Correct 92 ms 9640 KB Output is correct
10 Correct 56 ms 10148 KB Output is correct
11 Correct 50 ms 10228 KB Output is correct
12 Correct 53 ms 10148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 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 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 532 KB Output is correct
26 Correct 1 ms 532 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 91 ms 9624 KB Output is correct
36 Correct 103 ms 9620 KB Output is correct
37 Correct 92 ms 9640 KB Output is correct
38 Correct 99 ms 9632 KB Output is correct
39 Correct 99 ms 9636 KB Output is correct
40 Correct 92 ms 9796 KB Output is correct
41 Correct 95 ms 9772 KB Output is correct
42 Correct 96 ms 9636 KB Output is correct
43 Correct 95 ms 9636 KB Output is correct
44 Correct 94 ms 9640 KB Output is correct
45 Correct 56 ms 10148 KB Output is correct
46 Correct 50 ms 10228 KB Output is correct
47 Correct 53 ms 10148 KB Output is correct
48 Correct 54 ms 10144 KB Output is correct
49 Correct 56 ms 9940 KB Output is correct
50 Correct 60 ms 10144 KB Output is correct
51 Correct 57 ms 10136 KB Output is correct
52 Correct 54 ms 10148 KB Output is correct
53 Correct 56 ms 9936 KB Output is correct
54 Correct 62 ms 10144 KB Output is correct