이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(a) for(int i=0;i<a;++i)
#define ll long long
#define vi vector<int>
#define node S[j][i]
int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) {
vi CHILDREN(N);
vi LEAVES(N);
for(int i=1; i<N; ++i) {
CHILDREN[P[i]]++;
}
rep(N){
if (CHILDREN[i]==0) LEAVES[i] = true;
}
int res = 0;
vector<vi> C(M, CHILDREN);
vector<vi> L(M, LEAVES);
vector<vi> B(M, vi(N));
int numBranches = 0;
rep(N-1) {
for(int j = 0; j < M; ++j) {
if (L[j][node]) {
C[j][P[node]]--;
if (C[j][P[node]] == 0 && B[j][P[node]] == true) {
B[j][P[node]] = false;
numBranches--;
} else if (C[j][P[node]] == 0 && B[j][P[node]] == false) {
L[j][P[node]] = true;
}
}
else {
B[j][node] = true;
numBranches++;
}
}
if (numBranches == 0) res += 1;
}
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... |