typedeflonglong ll; usingnamespace std; constint N = 1e5 + 5; vector<int> G[N]; int n, x, y, cnt, id[N] = {1}, ans[N];
voiddfs1(int son, int father){//编号 for (auto kid:G[son]) { if (kid != father) dfs1(kid, son); } if (!id[son]) { if (id[father]) {//若父亲结点已被编号直接输出-1 printf("-1\n"); exit(0); } id[father] = id[son] = ++cnt; } }
voiddfs2(int son, int father, int color){//染色 ans[son] = color; for (auto kid:G[son]) { if (kid != father) dfs2(kid, son, (id[kid] == id[son] ? color : color ^ 1)); } }
intmain(){ cin >> n; for (int i = 0; i < n - 1; i++) { cin >> x >> y; G[x].push_back(y); G[y].push_back(x); } dfs1(1, 0); dfs2(1, 0, 0); for (int i = 1; i <= n; i++) putchar(ans[i] ? 'R' : 'B'); return0; }