Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef pair<int, int>P;
- bool cmp(P f, P s){
- if(f.first > s.first) return 0;
- if(f.first == s.first){
- if(f.second > s.second) return 0;
- else return 1;
- }else return 1;
- }
- int main()
- {
- int casee;
- cin >> casee;
- while(casee--)
- {
- int n;
- char str[1000000];
- int c=0;
- cin >> n;
- vector< pair<int, int> > vec;
- for(int i = 0; i < n; i++)
- {
- int x, y;
- cin >> x >> y;
- vec.push_back(make_pair(x, y));
- }
- sort(vec.begin(), vec.end(), cmp);
- int xx=0,yy=0,d=0,ck=0;
- for(int i=0;i<n;i++)
- {
- int x,y;
- x = vec[i].first;
- y = vec[i].second;
- if(x<xx)
- {
- ck=1;
- break;
- }
- if(y<yy)
- {
- ck=1;
- break;
- }
- if(xx<x)
- {
- int h=x-xx;
- while(h--)
- {
- str[c++] = 'R';
- }
- xx=x;
- }
- if(x==xx)
- {
- if(yy>y)
- {
- ck=1;
- break;
- }
- else{
- int h=y-yy;
- while(h--)
- {
- str[c++] = 'U';
- }
- yy=y;
- }
- }
- }
- str[c]='\0';
- if(ck==1)
- {
- cout<<"NO"<<endl;
- }
- else{
- cout<<"YES"<<endl;
- cout<<str<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement