Logo
(追記) (追記ここまで)

34270번 - Mob Grinder 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 2048 MB14131392.857%

문제

In a certain popular sandbox video game, one can build a structure called a mob grinder. A mob grinder consists of an $N\times M$ rectangular grid of tiles. Monsters, also known as "mobs," appear continuously at random places on the grid. The goal of a mob grinder is to move all of the monsters to the top-right tile in the grid, no matter where they originally appear. To accomplish this goal, each tile (except for the top-right tile) has a conveyor belt on it with a specified direction (up, right, down, or left). A monster on a conveyor belt gets moved to the orthogonally adjacent tile in the direction specified by the conveyor belt orientation.

Your job is to place a conveyor belt on each tile (other than the top-right corner) so that no matter where a monster appears on the grid, it will get moved to the top-right corner after a finite amount of time, without ever leaving the bounds of the grid. However, there is a limit on how many conveyor belts you can use of each orientation: your final design must have exactly $U$ conveyor belts going up, $R$ going right, $D$ going down, and $L$ going left.

You are asked to design multiple mob grinders, each with a specification of how many conveyor belts of each type you are allowed to use. Design a valid mob grinder that meets each specification, if possible.

입력

The first line of input contains an integer $T$ (1ドル \leq T \leq 10^5$): the number of mob grinders you need to design.

Each of the next $T$ lines of input contains six space-separated integers that describe one mob grinder specification. The first two integers, $N$ and $M,ドル (1ドル\leq N,M$ and $N\cdot M \leq 10^5)$ are the number of rows and columns in the grid, respectively. The last four, $U,ドル $R,ドル $D,ドル $L$ $(0 \leq U, R, D, L$ and $U+R+D+L = (N \cdot M)-1),ドル are the number of times you must use each conveyor belt orientation in your design.

It is guaranteed that the sum of $N\cdot M$ over all $T$ mob grinders does not exceed 10ドル^5$.

출력

Print $T$ mob grinder designs, one for each specification. Separate consecutive designs with a single empty line.

If it is impossible to construct a valid mob grinder respecting the given constraints for the given specification, print impossible. Otherwise, print an $N\times M$ grid of ASCII characters. The top-right tile must be a *. Every other character in the grid must be either U, R, D, or L, representing the orientation of the conveyor belt on that grid tile.

This problem is whitespace-sensitive. You must separate each mob grinder design with exactly one empty line (containing just a newline character). You must not print an empty line, or any other extraneous output, after the last mob grinder design (though the last line of output must be terminated with a newline). Please see the Sample Output for examples of how to correctly format your mob grinder designs.

제한

예제 입력 1

2
4 3 5 3 1 2
1 2 0 1 0 0

예제 출력 1

RR*
URU
UDU
ULL
R*

예제 입력 2

3
3 3 0 0 0 8
2 2 0 2 0 1
1 1 0 0 0 0

예제 출력 2

impossible
impossible
*

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2025 F번

  • 문제를 만든 사람: Mark Sturtevant
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /