# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1201745 | noop | September (APIO24_september) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
vector<int> g;
vector<bool> s;
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
g.resize(N,0);
s.resize(N,0);
int ans=0,t=0,c,p;
for (int i=1; i<N; i++){
g[F[i]]++;
}
for (int i=0; i<S[0].size(); i++){
c=S[0][i];
if (g[c]){
t++;
v[c]++;
}
p=F[c];
g[p]--;
if (!g[p] and s[p]){
t--;
}
if (!t){
ans++;
}
}
return ans;
}