#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair P; typedef pair PP; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=sta;i--) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair LP; int dx[4]={1,-1,0,0}; int dy[4]={0,0,1,-1}; templatebool chmax(T &a, const T &b) {if(abool chmin(T &a, const T &b) {if(b V[2]; int f(char c){ if(c=='R') return 0; else return 1; } void solve(){ cin >> n; rep(i,n){ cin >> c[i] >> x[i] >> y[i]; V[f(x[i])].push_back(PP(P(y[i],(f(c[i])+f(x[i])+1)%2),i)); } rep(i,2) sort(V[i].begin(),V[i].end()); for(auto &pp:V[0]){ pp.first.second=1-pp.first.second; } // rep(i,2) for(auto pp:V[i]){ // cout << i << " " << pp.first.second << " " << pp.first.first << endl; // } V[0].push_back(PP(P(mod,0),n)); int m=V[1].size(); int pos=0,num[2]={0,0}; vector ans={}; rep(i,m){ //cout << num[0]+(V[1][i].first.second) << " " << num[1] << endl; while((num[0]+(V[1][i].first.second==0)>V[0][pos].first.first) || (num[1]!=V[1][i].first.first)){ if(num[0]!=V[0][pos].first.first){ cout << "No" << endl; return; } ans.push_back(V[0][pos].second); num[V[0][pos].first.second]+=1; pos++; //cout << pos << endl; } ans.push_back(V[1][i].second); num[V[1][i].first.second]+=1; } while(pos visited; rep(i,n){ if(n<=ans[i]){ cout << "No" << endl; return; } if(visited[ans[i]]){ cout << "No" << endl; return; } visited[ans[i]]=true; if(k[f(x[ans[i]])]!=y[ans[i]]){ cout << "No" << endl; return; } k[f(c[ans[i]])]+=1; } cout << "Yes" << endl; rep(i,n){ cout << ans[i]+1 << ((i