Wesam and Omar
Practice
4 (2 votes)
Basics of greedy algorithms
Algorithms
Greedy algorithms
Problem
69% Success 604 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a grid of size 3*3 that has the following specifications:
- Each cell in the grid is either empty '.' or occupied '*'.
- you can't move to an occupied cell.
- Wesam starts at cell (1,1) and wants to reach Omar who is in cell (3,3).
- Wesam can move vertically, horizontally, and diagonally.
Note:If Wesam is standing at cell (x,y), he can go to :(x+1,y) , (x-1,y), (x,y+1) , (x,y-1), (x+1,y+1) , (x-1,y-1).
Note: rows are numbered from top to down, and columns are numbered from left to right.
Write a program to find if Wesam can reach Omar or not.
Input format:
- First line: T (number of test cases)
For each test case - 3 lines: 3 characters (denoting each cell in the grid.
It's guaranteed that cell (1,1) and cell (3,3) are empty.
Output format:
For each test case print "YES" (without quotes) if Wesam can reach Omar. Print "NO" (without quotes) otherwise.
Constraints
1<= T <= 100
Submissions
Please login to view your submissions
Similar Problems
Points:10
4 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Points:10
14 votes
Tags:
Basic ProgrammingAlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
3.Coprimes
Points:10
41 votes
Tags:
Ad-HocAlgorithmsCoprimeEasyGreedy Algorithms
Editorial