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>
#include "september.h"
#define INF 1e9
using namespace std;
typedef long long ll;
vector<int>adj[800005];
bool visited[800005];
int v = 0;
void dfs(int s){
if(visited[s]) return;
visited[s] = true;
++v;
for(auto u : adj[s]){
dfs(u);
}
}
int solve(int N, int M, vector<int> F, vector<vector<int>>S) {
for(int i = 0;i<N;i++){
adj[i].clear();
visited[i] = false;
}
for(int i =1; i < N;i++){
adj[F[i]].push_back(i);
}
int ans = 0;
for(int i =0;i<N-1;i++){
for(int j =0;j<M;j++)dfs(S[j][i]);
ans += !--v;
}
return ans;
}
# | 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... |