#include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; int n; char c[200000], x[200000]; int y[200000]; vector> vr, vb; vector g[200000]; bool used[200000][2]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> n; bool ok = true; for(int i = 0; i < n; i++) { cin >> c[i] >> x[i] >> y[i]; int ci = c[i] == 'R' ? 0 : 1; int xi = x[i] == 'R' ? 0 : 1; if(ci == xi){ if(used[y[i]][xi]) ok = false; used[y[i]][xi] = true; } if(x[i] == 'R'){ int s = c[i] == 'R' ? 1 : 0; vr.push_back({y[i], s, i}); // (B, R, m) -> (R, R, m)の順になる }else{ int s = c[i] == 'B' ? 1 : 0; vb.push_back({y[i], s, i}); // (R, B, m) -> (B, B, m)の順になる } } if(!ok){ cout << "No" << endl; return 0; } sort(vr.begin(), vr.end()); sort(vb.begin(), vb.end()); // for(int i = 0; i+1 < (int)vr.size(); i++){ // int idx1 = vr[i][2], idx2 = vr[i+1][2]; // g[idx1].push_back(idx2); // } // for(int i = 0; i+1 < (int)vb.size(); i++){ // int idx1 = vb[i][2], idx2 = vb[i+1][2]; // g[idx1].push_back(idx2); // } int idxr = 0, idxb = 0; int cntr = 0, cntb = 0; vector ans; // cout << vr.size() << ' ' << vb.size() << endl; while(idxr < vr.size() || idxb < vb.size()){ if(idxr < vr.size() && vr[idxr][1] == 1 && vr[idxr][0] == cntr){ ans.push_back(vr[idxr][2]); idxr++; cntr++; continue; } if(idxb < vb.size() && vb[idxb][1] == 1 && vb[idxb][0] == cntb){ ans.push_back(vb[idxb][2]); idxb++; cntb++; continue; } if(idxr < vr.size() && vr[idxr][0] == cntr){ ans.push_back(vr[idxr][2]); idxr++; cntb++; continue; } if(idxb < vb.size() && vb[idxb][0] == cntb){ ans.push_back(vb[idxb][2]); idxb++; cntr++; continue; } cout << "No" << endl; cout << -1 << endl; return 0; } // cout << idxb << ' ' << idxr << endl; cout << "Yes" << endl; for(int i : ans) cout << i+1 << ' '; cout << endl; }