7243: CodeChef TANDJ1 - Tom And Jerry 1
[Creator : ]
Description
There is a grid of size $10^5 \times 10^5$, covered completely in railway tracks. Tom is riding in a train, currently in cell (a, b), and Jerry is tied up in a different cell (c, d), unable to move. The train has no breaks. It shall move exactly KK steps, and then its fuel will run out and it shall stop.
In one step, the train must move to one of its neighboring cells, sharing a side. Tom can’t move without the train, as the grid is covered in tracks. Can Tom reach Jerry’s cell after exactly $K$ steps?
Note: Tom can go back to the same cell multiple times.
In one step, the train must move to one of its neighboring cells, sharing a side. Tom can’t move without the train, as the grid is covered in tracks. Can Tom reach Jerry’s cell after exactly $K$ steps?
Note: Tom can go back to the same cell multiple times.
Input
The first line contains an integer T, the number of test cases. Then the test cases follow.
Each test case contains a single line of input, five integers a, b, c, d, K.
Output
For each testcase, output in a single line "YES" if Tom can reach Jerry's cell in exactly KK moves and "NO" if not.
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).
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).
Constraints
$1≤T≤10^5$
$0 \leq a, b, c, d \leq 10^5$
$(a, b) \ne (c, d)$
$1 \leq K \leq 2 \cdot 10^5$
$0 \leq a, b, c, d \leq 10^5$
$(a, b) \ne (c, d)$
$1 \leq K \leq 2 \cdot 10^5$
Sample 1 Input
3
1 1 2 2 2
1 1 2 3 4
1 1 1 0 3
Sample 1 Output
YES
NO
YES
Test Case 1: A possible sequence of moves is $(1, 1) \to (1, 2) \to (2, 2)$.
Test Case 2: There is a possible sequence in 3 moves, but not in exactly 4 moves.
Test Case 3: A possible sequence of moves is $(1, 1) \to (1, 0) \to (0, 0) \to (1, 0)$.
Test Case 2: There is a possible sequence in 3 moves, but not in exactly 4 moves.
Test Case 3: A possible sequence of moves is $(1, 1) \to (1, 0) \to (0, 0) \to (1, 0)$.