We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSES Subordinates:
AC Code
#include "bits/stdc++.h" int dfs(int node, std::vector<std::vector<int>>& a, std::vector<int>& ans) { int temp = 0; for(auto& i : a[node]) temp += dfs(i, a, ans); return ans[node] = 1 + temp; } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); int n; std::cin >> n; std::vector<std::vector<int>> a(n + 1); std::vector<int> ans(n + 1, 0); for(int i = 2, x; i <= n; ++i) { std::cin >> x; a[x].push_back(i); } dfs(1, a, ans); for(int i = 1; i <= n; ++i) std::cout << ans[i] - 1 << " "; }
gives RTE on our grader. I think this is because our stack size is too small. Fix with ulimit -s unlimited: https://stackoverflow.com/questions/14471564/what-does-ulimit-s-unlimited-do
ulimit -s unlimited
The text was updated successfully, but these errors were encountered:
c376c84
No branches or pull requests
CSES Subordinates:
AC Code
gives RTE on our grader. I think this is because our stack size is too small. Fix with
ulimit -s unlimited
: https://stackoverflow.com/questions/14471564/what-does-ulimit-s-unlimited-doThe text was updated successfully, but these errors were encountered: