Diagonal movement solution codechef

Diagonal movement solution codechef

Given the coordinates (x,y)(x,y) of a point in 2-D plane. Find if it is possible to reach (x,y)(x,y) from (0,0)(0,0). The only possible moves from any coordinate (i,j)(i,j) are as follows: Diagonal movement solution codechef

  • Go to the point with coordinates (i+1,j+1)(i+1,j+1).
  • Go to the point with coordinates (i+1,j1)(i+1,j−1)
  • Go to the point with coordinates (i1,j+1)(i−1,j+1).
  • Go to the point with coordinates (i1,j1)(i−1,j−1).

Diagonal movement solution codechef

  • First line will contain TT, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, two integers x,yx,y.

Output Format

Diagonal movement solution codechef

For each test case, print YES if it is possible to reach (x,y)(x,y) from (0,0)(0,0), otherwise print NO.

You may print each character of the string in uppercase or lowercase (for example, the strings “yEs”, “yes”, “Yes” and “YES” will all be treated as identical).

Diagonal movement solution codechef

  • 1T21041≤T≤2⋅104
  • 109x,y109−109≤x,y≤109

Sample Input 1

Diagonal movement solution codechef

6
0 2
1 2
-1 -3
-1 0
-3 1
2 -1

Diagonal movement solution codechef

Diagonal movement solution codechef

YES
NO
YES
NO
YES
NO

Diagonal movement solution codechef

Test case 11: A valid sequence of moves can be: (0,0)(1,1)(0,2)(0,0)→(1,1)→(0,2).

Test case 22: There is no possible way to reach the point (1,2)(1,2) from (0,0)(0,0).

Test case 33: A valid sequence of moves can be: (0,0)(1,1)(0,2)(1,3)(0,0)→(−1,−1)→(0,−2)→(−1,−3).

Leave a Comment