이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//chockolateman
#include<bits/stdc++.h>
using namespace std;
int in_deegree[100005][10],positions[10];
vector<int> children[100005];
bool removed[100005][10];
bool set_to_remove[100005][10];
void init(int N,int M)
{
for(int i = 0 ; i < M ; i++)
{
positions[i] = 0;
for(int j = 0 ; j < N ; j++)
{
in_deegree[j][i] = 0;
children[j].clear();
removed[j][i] = false;
set_to_remove[j][i] = false;
}
}
}
int solve(int N, int M, std::vector<int> F,std::vector<std::vector<int>> S)
{
for(int i = 1 ; i < N ; i++)
{
children[F[i]].push_back(i);
for(int j = 0 ; j < M ; j++)
{
in_deegree[F[i]][j]++;
}
}
int counter = 0;
stack<int> removal_list;
while(positions[0] != N-1)
{
counter++;
for(int i = 0 ; i < M ; i++)
{
removal_list.push(S[i][positions[i]]);
set_to_remove[S[i][positions[i]]][i] = true;
positions[i]++;
}
while(!removal_list.empty())
{
int v = removal_list.top();
removal_list.pop();
for(int i = 0 ; i < M ; i++)
if(!removed[v][i])
{
if(!set_to_remove[v][i])
{
while(S[i][positions[i]] != v)
{
set_to_remove[S[i][positions[i]]][i] = true;
removal_list.push(S[i][positions[i]]);
in_deegree[S[i][positions[i]]][i]--;
positions[i]++;
}
set_to_remove[S[i][positions[i]]][i] = true;
removal_list.push(S[i][positions[i]]);
in_deegree[F[S[i][positions[i]]]][i]--;
positions[i]++;
}
removed[v][i] = true;
if(in_deegree[v][i]==0)
continue;
for(auto u : children[v])
{
if(!set_to_remove[u][i])
continue;
in_deegree[v][i]--;
removal_list.push(u);
}
}
}
}
init(N,M);
return counter;
}
# | 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... |