def input_int():
return int(input())
def input_int_list():
return [int(_) for _ in input().split()]
def input_str():
return input()
def input_str_list():
return [_ for _ in input().split()]
def print_solution(solution_list):
for solution in solution_list:
print(solution)
def print_solution_list(solution_list):
for solution in solution_list:
out = ''
for i in solution:
out += str(i) + ' '
print(out)
if __name__ == "__main__":
solution_list = []
t = input_int()
for _ in range(t):
n = input_int()
xy_map = {}
for __ in range(n):
x, y = map(int, input().split())
xy_map.setdefault(x, []).append(y)
map_key = list(xy_map.keys())
map_key.sort()
c_x = 0
c_y = 0
s = ''
for key in map_key:
if key > c_x:
s += 'R' * (key - c_x)
c_x = key
value = xy_map[key]
value.sort()
if value[0] < c_y:
solution_list.append(['NO'])
break
s += 'U' * (value[-1] - c_y)
c_y = value[-1]
else:
solution_list.append(['YES'])
solution_list.append([s])
print_solution_list(solution_list)
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
pair<int,int> p[n];
for(int i = 0; i < n; i++){
cin >> p[i].first >> p[i].second;
}
sort(p, p+n);
bool test = true;
for(int i = 0; i+1 < n; i++){
if(p[i].second > p[i+1].second){
test = false;
break;
}
}
if(!test){
printf("NO\n");
continue;
}
printf("YES\n");
string moves = "";
int x = 0, y = 0;
for(int i = 0; i < n; i++){
while(x < p[i].first){
moves.push_back('R');
x++;
}
while(y < p[i].second){
moves.push_back('U');
y++;
}
}
printf("%s\n", moves.c_str());
}
return 0;
}
489C - Given Length and Sum of Digits | 886B - Vlad and Cafes |
915A - Garden | 356A - Knight Tournament |
1330A - Dreamoon and Ranking Collection | 1692B - All Distinct |
1156C - Match Points | 1675A - Food for Animals |
1328C - Ternary XOR | 1689A - Lex String |
1708B - Difference of GCDs | 863A - Quasi-palindrome |
1478A - Nezzar and Colorful Balls | 1581B - Diameter of Graph |
404A - Valera and X | 908A - New Year and Counting Cards |
146A - Lucky Ticket | 1594C - Make Them Equal |
1676A - Lucky | 1700B - Palindromic Numbers |
702C - Cellular Network | 1672C - Unequal Array |
1706C - Qpwoeirut And The City | 1697A - Parkway Walk |
1505B - DMCA | 478B - Random Teams |
1705C - Mark and His Unfinished Essay | 1401C - Mere Array |
1613B - Absent Remainder | 1536B - Prinzessin der Verurteilung |