이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "september.h"
#include <vector>
using namespace std;
int K,i,j,idx,child[100005],w[100005],mx[100005],x;
vector<int> v[100005],u;
bitset<100005> vis;
void dfs(int x){
u.push_back(x);
child[x]=1;
for(int i:v[x]){
dfs(i);
child[x]+=child[i];
}
}
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S){
K=0;
u.clear();
for(i=0;i<N;i++){
v[i].clear();
mx[i]=0;
}
vis.reset();
for(i=1;i<N;i++){
v[F[i]].push_back(i);
}
for(j=0;j<M;j++){
for(i=0;i<N-1;i++){
mx[S[j][i]]=max(mx[S[j][i]],i+1);
}
}
dfs(0);
for(i=0;i<N;i++) w[u[i]]=i;
idx=1;
i=0;
while(idx<N){
K++;
for(;i<idx;i++){
x=S[M-1][i];
for(j=w[x];j<w[x]+child[x];j++){
if(vis[u[j]]){
j+=child[u[j]];
j--;
continue;
}
vis[u[j]]=1;
idx=max(idx,mx[u[j]]);
}
}
idx++;
}
return K;
}
# | 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... |