1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| #include <bits/stdc++.h> using namespace std; namespace Legendgod { namespace Read {
#ifdef Fread const int Siz = (1 << 21) + 5; char *iS, *iT, buf[Siz]; #define gc() ( iS == iT ? (iT = (iS = buf) + fread(buf, 1, Siz, stdin), iS == iT ? EOF : *iS ++) : *iS ++ ) #define getchar gc #endif template <typename T> void r1(T &x) { x = 0; char c(getchar()); int f(1); for(; !isdigit(c); c = getchar()) if(c == '-') f = -1; for(; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); x *= f; } template <typename T, typename...Args> void r1(T &x, Args&...arg) { r1(x), r1(arg...); } #undef getchar }
using namespace Read;
const int maxn = 4e5 + 5;
int n, m; vector<int> a[maxn]; int tmp[maxn], tot;
int head[maxn], cnt(1); struct Edge { int to, next, ps; }edg[maxn << 1]; int vise[maxn << 1];
void add(int u,int v,int ps) { edg[++ cnt] = (Edge) {v, head[u], ps}, head[u] = cnt; }
vector<int> ot[maxn], in[maxn]; int vis[maxn], mx(0); vector<int> ans;
void dfs(int p) { vis[p] = 1; while(head[p] != 0 && vise[head[p]]) head[p] = edg[head[p]].next; if(head[p] == 0) return ; vise[head[p]] = vise[head[p] ^ 1] = 1; int x = edg[head[p]].ps; dfs(edg[head[p]].to); ans.emplace_back(x);
}
vector<int> out;
int buf[maxn];
signed main() { int i, j; r1(m); for(i = 1; i <= m; ++ i) { r1(n); mx = max(mx, n); for(j = 1; j <= n; ++ j) { int x; r1(x); a[i].emplace_back(x); tmp[++ tot] = x; } } sort(tmp + 1, tmp + tot + 1); tot = unique(tmp + 1, tmp + tot + 1) - tmp - 1; int ts(0); for(i = 1; i <= m; ++ i) { for(j = 0; (unsigned) j < a[i].size(); ++ j) { int id = lower_bound(tmp + 1, tmp + tot + 1, a[i][j]) - tmp; ++ buf[id]; add(i, m + id, ts), add(id + m, i, ts), ++ ts; } } for(i = 1; i <= tot; ++ i) if(buf[i] & 1) return puts("NO"), 0;
for(i = 1; i <= m + tot; ++ i) if(head[i]) dfs(i);
out.resize(ts); int op = 1;
for(int i : ans) out[i] = op, op ^= 1; puts("YES"); char prt[2] = {'L', 'R'}; op = 0; for(i = 1; i <= m; ++ i) { for(j = 0; (unsigned) j < a[i].size(); ++ j) printf("%c", prt[out[op ++]]); puts(""); } return 0; }
}
signed main() { return Legendgod::main(), 0; }
|