# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1166900 | tch1cherin | Cat in a tree (BOI17_catinatree) | C++17 | 322 ms | 589824 KiB |
#include<bits/stdc++.h>
using namespace std;
int N,D,A,P,X[1<<20],i=1;
deque<int>G[1<<20];
int main() {
for(cin>>N>>D;cin>>P,i<N;)G[P].push_back(i++);
for(A=i--;~i;)for(int j:G[i--])
if(++X[j]+X[i]<D)X[i]=max(X[i],X[j]),--A;
else X[i]=min(X[i],X[j]);
cout<<A;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |