9123: Puzzle: Herugolf

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述


Grammy is a puzzle master. Today, she is playing a variant of "Herugolf" puzzle.

The puzzle consists of an infinitely large square grid. Initially, there is a golf ball at the origin (0,0)(0,0)(0,0). A strength parameter nnn is given so that you can hit the ball at most nnn times.

However, assume the ball is at (xs,ys)(x_s,y_s)(xs,ys) before the (i+1)(i+1)(i+1)-th hit, there are only 444 possible ways to hit the ball:


  •  Move right through segment (xs,ys)−(xs+n−i,ys)(x_s,y_s)-(x_s+n-i,y_s)(xs,ys)(xs+ni,ys), and land on (xs+n−i,ys)(x_s+n-i,y_s)(xs+ni,ys)
  •  Move left through segment (xs,ys)−(xs−n+i,ys)(x_s,y_s)-(x_s-n+i,y_s)(xs,ys)(xsn+i,ys), and land on (xs−n+i,ys)(x_s-n+i,y_s)(xsn+i,ys)
  •  Move up through segment (xs,ys)−(xs,ys+n−i)(x_s,y_s)-(x_s,y_s+n-i)(xs,ys)(xs,ys+ni), and land on (xs,ys+n−i)(x_s,y_s+n-i)(xs,ys+ni)
  •  Move down through segment (xs,ys)−(xs,ys−n+i)(x_s,y_s)-(x_s,y_s-n+i)(xs,ys)(xs,ysn+i), and land on (xs,ys−n+i)(x_s,y_s-n+i)(xs,ysn+i)


Note that the ball will not fall into the hole on the segment.

Additionally, the ball should not visit a point twice. During a hit, each point on the segment is considered visited by the ball.

The goal is to hit the golf ball into the only hole (x,y)(x,y)(x,y).



The left picture illustrates an empty puzzle, and the right picture shows a solution to the puzzle.

Grammy surely knows how to solve the puzzle, but she decided to give you a quiz. Please solve the puzzle.

输入格式

There are multiple test cases.
The first line contains the number of test cases TTT (1≤T≤10001 \leq T \leq 10001T1000).
Each of the following TTT lines contains two positive integers n,x,yn,x,yn,x,y (1≤n≤105,−n(n+1)2≤x,y≤n(n+1)21 \leq n \leq 10^5, -\frac{n(n+1)}{2} \leq x,y \leq \frac{n(n+1)}{2}1n105,2n(n+1)x,y2n(n+1)), denoting the parameter nnn
It is guaranteed that there are at most 555 test cases with n>50n>50n>50.

输出格式

For each test case:
If the solution does not exist, output "NO\texttt{NO}NO" on a single line.
Otherwise, output "YES\texttt{YES}YES" on the first line, then output a string consisting of characters "L\texttt{L}L", "R\texttt{R}R", "U\texttt{U}U", and "D\texttt{D}D", denoting the directions of each hit.
If there are multiple solutions, output any.

输入样例 复制

2
6 3 1
6 7 7

输出样例 复制

YES
DRUUL
NO

分类标签