#include <bits/stdc++.h>#include <functional>using namespace std;int main() { long long n; cin >> n; vector<vector<long long>> f(n); for (long long i = 0; i < n-1; i++) { long long tmp; cin >> tmp; f[tmp-1].push_back(i+1); } long long happy[n]; for (long long i = 0; i < n; i++) cin >> happy[i]; for (long long i = 0; i < n; i++) { long long tmp; cin >> tmp; happy[i] += tmp; } long long ans = 0; function<void(long long, long long)> dfs = [&amp;](long long i, long long hy) -> void{ if (f[i].empty()) { //hy += happy[i]; ans = max(hy, ans); //hy -= happy[i]; return; } //hy += happy[i]; for (long long x : f[i]) { hy += happy[x]; dfs(x, hy); hy -= happy[x]; } }; dfs(0, happy[0]); cout << ans; }感觉我这代码没毛病,gpt没指出错误。到底是哪儿有毛病啊有没有佬能指点一下