제출 #1038961

#제출 시각아이디문제언어결과실행 시간메모리
1038961HanksburgerCat in a tree (BOI17_catinatree)C++17
0 / 100
2 ms5040 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[200005]; int n, d, s, x; int f(int u) { int m=1e9; for (int v:adj[u]) m=min(m, f(v)); if (m+1>=d) s++, m=-1; return m+1; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d; for (int i=1; i<n; i++) { cin >> x; adj[x].push_back(i); } f(0); cout << s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...