ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212721 | #3829. C | zhouzhichen123456 | Compile Error | / | / | C++ | 615b | 2024-10-20 10:08:17 | 2024-10-20 12:39:38 |
answer
#include <iostream>
#include <vector>
int dfs(int node, int depth, std::vector<std::vector<int>>& tree) {
if (tree[node].empty()) return depth;
int total_depth = 0;
for (int child : tree[node]) {
total_depth += dfs(child, depth + 1, tree);
}
return total_depth;
}
int main() {
int n;
std::cin >> n;
std::vector<std::vector<int>> tree(n + 1);
for (int i = 0; i < n - 1; ++i) {
int x, y;
std::cin >> x >> y;
tree[x].push_back(y);
}
int result = dfs(1, 0, tree);
std::cout << result << std::endl;
return 0;
}
详细
answer.code:4:57: error: '>>' should be '> >' within a nested template argument list int dfs(int node, int depth, std::vector<std::vector<int>>& tree) {\x0d ^ answer.code: In function 'int dfs(int, int, std::vector<std::vector<int> >&)': answer.code:7:22: error: range-based 'for' loops are not allowed in C++98 mode for (int child : tree[node]) {\x0d ^ answer.code: In function 'int main()': answer.code:16:32: error: '>...