Skip to main content

Intuit

Intuit OA-5 2024

Problem Description

Alex is a stunt performer in a circus arena structured as an m*n grid. He is preparing for an exciting new stunt where a fire ignites from a given point (fx, fy). Alex begins his stunt at a start point (ix, iy) and needs to reach a destination point (jx, jy).

Both Alex and the fire move at the same speed—1 step per second. Alex can move either horizontally or vertically, while the fire spreads in all directions along the x and y axes from its starting location.

Alex has t different scenarios where each scenario specifies his starting point, ending point, and the fire's starting position. However, he's unsure if he can safely reach the destination in each case before the fire catches him.

Your task is to help Alex determine for each scenario whether it's possible for him to reach the destination without being overtaken by the fire.

Input Format:

  • First line contains three integers: m, n, and t (the number of test cases).
  • The next t lines contain 6 integers:
    • ix, iy: Starting point of Alex
    • jx, jy: Ending point of Alex
    • fx, fy: Fire starting point

Output Format:

  • For each test case, print "YES" if Alex can reach the destination without getting caught by the fire, otherwise print "NO".

Example

Sample Input:

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

Sample Output:

YES
NO
YES
NO
NO