/in/foo.cc:3:5: error: 'vector' does not name a type
vector<int> rootHeights; // rootHeights[i]表示以节点i为根的树的高度
^~~~~~
/in/foo.cc:4:5: error: 'vector' does not name a type
vector<int> h; // h[i]表示以节点i为根的子树的高度
^~~~~~
/in/foo.cc:10:40: error: 'vector' has not been declared
int dfs_zeroRoot(int node, int pa, vector<vector<int>>& neighbors){
^~~~~~
/in/foo.cc:10:46: error: expected ',' or '...' before '<' token
int dfs_zeroRoot(int node, int pa, vector<vector<int>>& neighbors){
^
/in/foo.cc:23:43: error: 'vector' has not been declared
void dfs_ChangeRoot(int node, int pa, vector<vector<int>>& neighbors){
^~~~~~
/in/foo.cc:23:49: error: expected ',' or '...' before '<' token
void dfs_ChangeRoot(int node, int pa, vector<vector<int>>& neighbors){
^
/in/foo.cc:45:5: error: 'vector' does not name a type
vector<int> findMinHeightTrees(int n, vector<vector<int>>& edges) {
^~~~~~
/in/foo.cc: In member function 'int Solution::dfs_zeroRoot(int, int, int)':
/in/foo.cc:12:26: error: 'neighbors' was not declared in this scope
for(auto& child: neighbors[node]){
^~~~~~~~~
/in/foo.cc:14:74: error: 'max' was not declared in this scope
height = max(height, dfs_zeroRoot(child, node, neighbors) + 1); // 以节点为根的子树高度 = 所有子节点子树的最大高度 + 1
^
/in/foo.cc:16:9: error: 'h' was not declared in this scope
h[node] = height; // 记录这个值
^
/in/foo.cc: In member function 'void Solution::dfs_ChangeRoot(int, int, int)':
/in/foo.cc:27:26: error: 'neighbors' was not declared in this scope
for(auto& child: neighbors[node]){
^~~~~~~~~
/in/foo.cc:28:16: error: 'h' was not declared in this scope
if(h[child] > maxH){
^
/in/foo.cc:35:9: error: 'rootHeights' was not declared in this scope
rootHeights[node] = maxH + 1; // 根节点node的高度就等于最大子树高度 + 1
^~~~~~~~~~~
/in/foo.cc:36:53: error: 'min' was not declared in this scope
minHeight = min(minHeight, rootHeights[node]); // 更新最小高度
^
/in/foo.cc:38:26: error: 'neighbors' was not declared in this scope
for(auto& child: neighbors[node]){
^~~~~~~~~
/in/foo.cc:40:13: error: 'h' was not declared in this scope
h[node] = (h[child] == maxH ? secondMaxH : maxH) + 1; // 换根后,当前节点变成子节点的子节点,更新其为根的子树高度
^