#include #include using namespace std;int main() { long long n; cin >> n; vector> f(n); for (long long i = 0; i long long tmp; cin >> tmp; f[tmp-1].push_back(i+1); } long long happy[n]; for (long long i = 0; i cin >> happy[i]; for (long long i = 0; i long long tmp; cin >> tmp; happy[i] += tmp; } long long ans = 0; function dfs = [&](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 }感觉我这代码没毛病,gpt没指出错误。到底是哪儿有毛病啊有没有佬能指点一下