Should be intuitive
\tint dfs(const vector >& g, int i, long& maxScore, long& res){\n        long score = 1, sum = 0;\n        for(int x : g[i]){\n            int cnt = dfs(g, x, m
\tint dfs(const vector<vector<int> >& g, int i, long& maxScore, long& res){\n        long score = 1, sum = 0;\n        for(int x : g[i]){\n            int cnt = dfs(g, x, maxScore, res);\n            score *= cnt;\n            sum += cnt;\n        }\n        score *= g.size()-sum-(i!=0);\n        if(score>maxScore) maxScore = score, res = 1;\n        else if(score == maxScore) ++res;\n        return sum+1;\n    }\n    int countHighestScoreNodes(const vector<int>& parents) {\n        long n = parents.size(), res = 0, maxScore = 0;\n        vector<vector<int> > g(n);\n        for(int i=1; i<n; ++i) g[parents[i]].push_back(i);\n        dfs(g, 0, maxScore, res);\n        return res;\n    }
[]