Language: C++

/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
    
     
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } 
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const pair<T, U> &_p) { _out << _p.first << ' ' << _p.second; return _out; }
template<typename T, typename U> inline istream &operator>> (istream &_in, pair<T, U> &_p) { _in >> _p.first >> _p.second; return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const vector<T> &_v) { if (_v.empty()) { return _out; } _out << _v.front(); for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const unordered_map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define rank rank228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb pb
const string FILENAME = "input";
const int MAXN = 100228;
 

int n;
int root[2];
int jump[MAXN];
int sz[MAXN];
int dist[MAXN];
bool inpath[MAXN];
vector<int> g[MAXN];
vector<int> path;

 
void dfs(int u, int p, int t) {
    if (dist[root[t]] < dist[u]) {
        root[t] = u;
    }
    jump[u] = p;
    sz[u] = 1;
    for (auto v: g[u]) {
        if (v != p) {
            dist[v] = dist[u] + 1;
            dfs(v, u, t);
            sz[u] += sz[v];
        }
    }
}

 
vector<int> solve() {
    int id = 0;
    vector<int> res;
    for (auto u: path) {
        int uk = ++id;
        for (auto v: g[u]) {
            if (!inpath[v]) {
                res.pb(++id);
            }
        }
        res.pb(uk);
    }
    return res;
}

 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 //   read(FILENAME);
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v; 
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    root[0] = 1;
    for (int i = 0; i < 2; i++) {
        dist[root[0]] = 0; 
        dfs(root[0], root[0], 0);
    }
    dist[root[0]] = 0;
    dfs(root[0], root[0], 1);
    int cur = root[1];
    while (cur != root[0]) {
        path.pb(cur); 
        inpath[cur] = 1;
        cur = jump[cur];
    }
    path.pb(root[0]);
    inpath[root[0]] = 1;
    for (auto u: path) {
        for (auto v: g[u]) {
            if (!inpath[v] && sz[v] > 1) {
                cout << -1; 
                return 0;
            }
        }
    }
    vector<int> st0 = solve();
    reverse(all(path));
    vector<int> st1 = solve();
    if (st0 > st1) {
        swap(st0, st1);
    }
    for (auto x: st0) {
        cout << x << ' ';
    }
    cout << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'std::vector<int> solve()':
a.cc:63:12: error: 'class std::vector<int>' has no member named 'pb'
   63 | #define pb pb
      |            ^~
a.cc:101:21: note: in expansion of macro 'pb'
  101 |                 res.pb(++id);
      |                     ^~
a.cc:63:12: error: 'class std::vector<int>' has no member named 'pb'
   63 | #define pb pb
      |            ^~
a.cc:104:13: note: in expansion of macro 'pb'
  104 |         res.pb(uk);
      |             ^~
a.cc: In function 'int main()':
a.cc:63:12: error: 'class std::vector<int>' has no member named 'pb'
   63 | #define pb pb
      |            ^~
a.cc:119:14: note: in expansion of macro 'pb'
  119 |         g[u].pb(v);
      |              ^~
a.cc:63:12: error: 'class std::vector<int>' has no member named 'pb'
   63 | #define pb pb
      |            ^~
a.cc:120:14: note: in expansion of macro 'pb'
  120 |         g[v].pb(u);
      |              ^~
a.cc:63:12: error: 'class std::vector<int>' has no member named 'pb'
   63 | #define pb pb
      |            ^~
a.cc:131:14: note: in expansion of macro 'pb'
  131 |         path.pb(cur);
      |              ^~
a.cc:63:12: error: 'class std::vector<int>' has no member named 'pb'
   63 | #define pb pb
      |            ^~
a.cc:135:10: note: in expansion of macro 'pb'
  135 |     path.pb(root[0]);
      |          ^~