Questions surface: https: //codeforces.com/contest/1294/problem/B
Subject to the effect:
Robot from (0,0), he can only up the 'U' or right 'R' walk
Coordinate system with a lot of parcels, respectively, at some point
The robot needs to go past all these parcels are collected
Q. Can it be done
If so, then move output mode, the output of the same moves lexicographically smallest solution
Problem-solving ideas:
pair or ordered structure, x and y are any priority, because the next parcel must be right at the current robot position / over / upper right
Otherwise direct output NO, this indicates the presence of possible moves
When the output moves, attention can first with 'R' on the use of 'R', because the big 'R' 'U' lexicographic order than (i.e., before and then on the right)
According to the analog
1 /* 2 Written By StelaYuri 3 On 2020/01/22 4 */ 5 #include<bits/stdc++.h> 6 using namespace std; 7 typedef pair<int,int> P; 8 P pnt[1050];//使用pair默认先x再y 9 string ans; 10 void add(int up,int right){ 11 int i; 12 for(i=0;i<right;i++) 13 ans+="R"; 14 for(i=0;i<up;i++) 15 ans+="U"; 16 }//先R再U 17 void solve(){ 18 int n,i; 19 ans=""; 20 cin>>n; 21 pnt[0]=P(0,0); 22 for(i=1;i<=n;i++) 23 cin>>pnt[i].first>>PNT [I] .second; 24 Sort (PNT + . 1 , PNT + . 1 + n-); 25 for (I = . 1 ; I <= n-; I ++ ) { 26 is IF (PNT [I] .first> PNT [I- . 1 ] && PNT .first [I] .second <PNT [I- . 1 ] .second) { // If the next point is greater than the current point x, y and less than the current point, obviously the absence of 27 COUT << " nO \ n- " ; 28 return ; 29 } 30 the Add (PNT [I] .second-PNT [I- . 1 ] .second, PNT [I] .first-PNT [I- . 1 ] .first); 31 is } 32 cout<<"YES\n"<<ans<<'\n'; 33 } 34 int main(){ 35 ios::sync_with_stdio(0); 36 cin.tie(0);cout.tie(0); 37 int T;cin>>T; 38 while(T--) 39 solve(); 40 41 return 0; 42 }