-
个人简介
#include <bits/stdc++.h> using namespace std; vector children[25]; int max_depth = 1; void dfs(int node, int depth) { max_depth = max(max_depth, depth); for (int child : children[node]) { dfs(child, depth + 1); } } int main() { int n; cin >> n; for (int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b; children[a].push_back(b); } dfs(1, 1); cout << max_depth; return 0; }
-
通过的题目
-
最近活动
-
最近编写的题解
This person is lazy and didn't write any solutions.
题目标签
- 递归
- 6
- 树结构
- 5
- 循环语句
- 4
- 字符型
- 1
- 数据结构
- 1
- 链表
- 1
- 容器
- 1
- vector
- 1
- 位运算
- 1
- 一维数组
- 1
- 搜索
- 1
- 结构体
- 1