This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
const int MN=3e5+5;
vector<int>v[MN];
bool vis[MN];
int par[MN];
void dfs(int a){
vis[a]=1;
for(auto b:v[a]){
if(vis[b]==1)continue;
dfs(b);
}
}
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
for(int i=0;i<N;i++){
v[i].clear();
vis[i]=0;
}
for(int i=1;i<N;i++){
par[i]=F[i];
v[F[i]].pb(i);
}
int k=0;
for(auto a:S[0]){
if(vis[a]==0){
k++;
dfs(a);
}
}
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... |