Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define pb emplace_back
- #define AI(i) begin(i), end(i)
- using namespace std;
- using ll = long long;
- #ifdef KEV
- #define DE(args...) kout("[ " + string(#args) + " ] = ", args)
- void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
- void kout(){ cerr << endl; }
- template<class T1, class ...T2> void kout(T1 a, T2 ...e) { cerr << a << ' ', kout(e...); }
- #else
- #define DE(...) 0
- #define deubg(...) 0
- #endif
- const int MAX_N = 300010;
- vector<int> edge[MAX_N];
- int n;
- void dfs(int x, int lst = -1) {
- for (int u : edge[x])
- if (u != lst)
- dfs(u, x);
- }
- signed main(){
- ios_base::sync_with_stdio(0), cin.tie(0);
- cin >> n;
- for (int i = 1, a, b;i < n;++i) {
- cin >> a >> b;
- edge[a].pb(b);
- edge[b].pb(a);
- }
- dfs(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement