1 条题解
-
1
// https://dashoj.com/p/130 #include <bits/stdc++.h> using namespace std; int n; map<int, vector<int>> tree; void dfs(int x) { cout << x << ' '; sort(tree[x].begin(), tree[x].end()); for (int i: tree[x]) dfs(i); } int main() { cin >> n; for (int i = 1; i < n; i++) { int x, y; cin >> x >> y; tree[x].push_back(y); } dfs(1); cout << endl; return 0; }
信息
- ID
- 130
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 36
- 已通过
- 20
- 上传者