이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
int solve(int N, int M, vector<int> F, vector<vector<int>> S) {
vector<int> cnt_S(N);
vector<int> cnt_ch(N);
vector<bool> flag(N);
for (int i = 1; i < N; i++) {
cnt_ch[F[i]]++;
}
int cnt_bad = 0;
int res = 0;
for (int i = 0; i < N - 1; i++) {
for (int j = 0; j < M; j++) {
int u = S[j][i];
cnt_bad -= (cnt_S[u] != 0 && cnt_S[u] != M);
cnt_S[u]++;
cnt_bad += (cnt_S[u] != 0 && cnt_S[u] != M);
}
int u = S[0][i];
cnt_bad -= (flag[F[u]] && cnt_ch[F[u]] > 0);
flag[u] = true;
cnt_ch[F[u]]--;
cnt_bad += (flag[F[u]] && cnt_ch[F[u]] > 0);
cnt_bad += (flag[u] && cnt_ch[u] > 0);
if (cnt_bad == 0) {
res++;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |