Skip to main content

Intuit

Intuit OA 2024 - Circus Fire 1


Jimmy is a stunt master in a circus which is shaped like a matrix m*n. Jimmy is preparing for a new stunt where fire starts from a point (fx, fy). Jimmy starts from a point (ix, iy) and reaches point (jx, jy).

Jimmy moves 1 step per second either horizontally or vertically. Fire spreads from the initial point with a speed of 1 step per second along the x and y axes from the initial starting point.

Jimmy has t combinations of start, end, and fire starting positions, but he is unsure if all places will allow him to reach the endpoint without getting caught by the fire.

Can you help Jimmy identify which combinations he can choose for the stunt?

Jimmy moves either horizontally or vertically at 1 step per second. Fire spreads in all directions from the fire's starting point, also at 1 step per second.

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 Jimmy
    • jx, jy: Ending point of Jimmy
    • fx, fy: Fire starting point

Output Format:

  • For each test case, print "YES" if Jimmy 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