/* -*- coding: utf-8 -*- * * 1328.cc: No.1328 alligachi-problem - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; const char ccs[] = "RB"; enum { R = 0, B = 1 }; /* typedef */ typedef pair pii; typedef vector vpii; /* global variables */ vpii wcs[2][2]; int cis[2][2], as[MAX_N]; /* subroutines */ inline int c2i(char c) { return (c == 'R') ? R : (c == 'B') ? B : -1; } inline int wcsize(int c, int x, int y) { vpii &wc = wcs[c][x]; int k = 0; for (int i = cis[c][x]; k < 2 && i < wc.size() && wc[i].first == y; i++, k++); return k; } inline int wcget(int c, int x) { return wcs[c][x][cis[c][x]++].second; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { char s[8], t[8]; int y; scanf("%s%s%d", s, t, &y); int c = c2i(s[0]), x = c2i(t[0]); wcs[c][x].push_back(pii(y, i)); } for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) sort(wcs[i][j].begin(), wcs[i][j].end()); for (int i = 0, rn = 0, bn = 0; i < n; i++) { if (wcsize(R, R, rn) == 1 && wcsize(B, R, rn) == 0) as[i] = wcget(R, R), rn++; else if (wcsize(B, B, bn) == 1 && wcsize(R, B, bn) == 0) as[i] = wcget(B, B), bn++; else if (wcsize(R, B, bn) > 0 && wcsize(R, R, rn) == 0 && wcsize(B, R, rn) == 0) as[i] = wcget(R, B), rn++; else if (wcsize(B, R, rn) > 0 && wcsize(R, B, bn) == 0 && wcsize(B, B, bn) == 0) as[i] = wcget(B, R), bn++; else { puts("No"); return 0; } //printf("as[%d]=%d\n", i, as[i]); } puts("Yes"); for (int i = 0; i < n; i++) printf("%d%c", as[i] + 1, (i + 1 < n) ? ' ' : '\n'); return 0; }