GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday 13 May 2022

[Solution] Robots Codeforces Solution | Codeforces Problem Solution 2022

B. Robots
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

There is a field divided into n rows and m columns. Some cells are empty (denoted as E), other cells contain robots (denoted as R).

You can send a command to all robots at the same time. The command can be of one of the four types:

  • move up;
  • move right;
  • move down;
  • move left.

Solution Click Below:-  CLICK HERE

When you send a command, all robots at the same time attempt to take one step in the direction you picked. If a robot tries to move outside the field, it explodes; otherwise, every robot moves to an adjacent cell in the chosen direction.

You can send as many commands as you want (possibly, zero), in any order. Your goal is to make at least one



 robot reach the upper left corner of the field. Can you do this without forcing any of the robots to explode?

Input

The first line contains one integer t (1t5000) — the number of test cases.

Each test case starts with a line containing two integers n and m (1n,m5) — the number of rows and the number of columns, respectively. Then n lines follow; each of them contains a string of m characters. Each character is either E (empty cell} or R (robot).

Additional constraint on the input: in each test case, there is at least one robot on the field.

Output

If it is possible to make at least one robot reach the upper left corner of the field so that no robot explodes, print YES. Otherwise, print NO.

Join Now for Solution:- 

No comments:

Post a Comment