Question: Please use JAVA to solve this question, Thanks!!! 2. Move the patterns ALL Description On an nxn map, there are some weird patterns. The same

Please use JAVA to solve this question, Thanks!!!

Please use JAVA to solve this question, Thanks!!! 2. Move the patterns

2. Move the patterns ALL Description On an nxn map, there are some weird patterns. The same numbers are connected into a pattern, ensure that the same numbers are connected. Connectivity is defined as-if two squares share an edge, then the two squares are connected; if A and B are connected, B and C Connected, then A and C are connected Different numbers compose multiple patterns, as shown in the figure below 1 2 3 1 1 11 4!4 41 (41 ( 4141 12:2 | 41 21 4 41 3 Then there are k operations, which are executed in sequence. Each operation will move a specified pattern by a unit distance in one direction. If the movement will be blocked by other patterns or move out of the map boundary, this movement will fail and this operation will be ignored. 135 left 30 H 13 sec seconds left There are two numbers in the first line, n and k Next n lines, each line has n characters. The character O means that the grid is empty, and the characters 1 to 9 indicate that the numbered pattern occupies this grid. In the next k lines, each line has a number from 1 to 9 and a capital letter. The number represents the number of the pattern to be operated. L stands for moving one square to the left; U stands for moving up one square; R stands for moving one square to the right;D stands for moving down one square. ALL 1 Output An nxn map, representing the final appearance of the map after k operations 2 3 Sample Input 84 00000000 10044000 10040000 10040000 00440220 00040020 00044030 00000000 1 L 2 D 3 R 10 Sample Output 10000000 10044000 10040000 00040000 00440220 00040020 00044003 00000000 Data range For 30% of the data, n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!