아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Grid travel

시간 제한1초메모리 제한1024 MB

요약
직사각형 격자와 두 점이 주어질 때, 두 점 사이의 가장 긴 단순 경로를 U, D, L, R로 된 이동 문자열로 출력한다.
난이도

보통10점 중 7점

유형
그리디, 구현, 시뮬레이션, 완전 탐색
정답자
아직 제출이 없습니다

문제

You are given a rectangular grid consisting of r × c points. The lower left corner has coordinates (1,1), the upper right corner has coordinates (c,r). The neighbors of a point (x,y) are the points (x − 1,y), (x + 1,y), (x,y − 1), and (x,y + 1), if they exist. A path is a sequence of points such that subsequent points are neighbors and each point appears on the path at most once.

Given two distinct points (xs,ys) and (xf,yf), find one longest path from (xs,ys) to (xf,yf).

입력

The first line of the input file contains an integer t specifying the number of test cases. Each test case is preceded by a blank line.

Each test case consists of a single line with six integers – r, c, xs, ys, xf, yf.

You may assume that 1 ≤ r,c ≤ 100 and rc ≥ 2.

출력

For each test case, output a single string describing one possible longest path. If there are multiple longest paths, output any one of them.

A path a1,a2,…,ak is described by a string consisting of k − 1 letters U, D, L, R. The i-th letter in the string describes the move from point ai to ai+1:

  • If ai = (x,y) and ai+1 = (x,y + 1), the i-th letter should be U.
  • If ai = (x,y) and ai+1 = (x,y − 1), the i-th letter should be D.
  • If ai = (x,y) and ai+1 = (x + 1,y), the i-th letter should be R.
  • If ai = (x,y) and ai+1 = (x − 1,y), the i-th letter should be L.

힌트

first example:

second example:

예제1

  1. 예제 1

    입력
    2
    
    1 10 2 1 4 1
    
    3 3 1 1 2 2
    
    예상 출력
    RR
    RRUULLDR