이 제출은 이전 버전의 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 S[j][i] S[0][i]
// two pointers?
int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) {
vi CHILDREN(N);
vector<bool> LEAVES(N);
for(int i=1; i<N; ++i) {
CHILDREN[P[i]]++;
}
rep(N){
if (CHILDREN[i]==0) LEAVES[i] = true;
}
int res =INT_MAX;
for (int j =0; j < M; ++j) {
int tempres = 0;
int BCNTR = 0;
vi C = CHILDREN;
vector<bool> L=LEAVES;
vector<bool> B(N,false);
rep(N-1) {
if (L[S[j][i]]) {
C[P[S[j][i]]]--;
//cout << "IS LEAF "<<S[j][i] << endl;
if (C[P[S[j][i]]] == 0 && B[P[S[j][i]]]== true) {
B[P[S[j][i]]] = false;
BCNTR--;
//cout << "RMV BRANCH " << P[S[j][i]] << endl;
}
else if (C[P[S[j][i]]]==0 && B[P[S[j][i]]]==false) {
L[P[S[j][i]]] = true;
//cout << "ADD LEAF " << P[S[j][i]]<< endl;
}
} else {
B[S[j][i]] = true;
BCNTR++;
//cout << "ADD BRANCH " << S[j][i]<<endl;
}
if(BCNTR==0) {
tempres++;
//cout << "RES++" << endl;
}
}
res = min(tempres, 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... |