Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<set>
- #include<iomanip>
- #include<algorithm>
- #include<vector>
- using namespace std;
- int main(){
- int t, n, x, y, f;
- vector<pair<int, int> > v;
- vector<char> res;
- cin >> t;
- for(int tc = 0; tc < t; tc++){
- cin >> n;
- v.clear();
- res.clear();
- for(int i = 0; i < n; i++){
- cin >> x >> y;
- v.push_back({x, y});
- }
- sort(v.begin(), v.end(),
- [](pair<int, int> a, pair<int, int> b){
- if(a.second == b.second){
- return a.first < b.first;
- }
- return a.second < b.second;
- });
- x = 0;
- y = 0;
- f = 1;
- for(int i = 0; i < (int)v.size(); i++){
- if(v[i].first < x || v[i].second < y){
- cout << "NO\n";
- f = 0;
- break;
- }
- for(; x < v[i].first; x++){
- res.push_back('R');
- }
- for(; y < v[i].second; y++){
- res.push_back('U');
- }
- }
- if(f){
- cout << "YES\n";
- for(int i = 0; i < (int)res.size(); i++){
- cout << res[i];
- }
- cout << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement