## Editorial for Yet Another Contest 6 P3 - No More Cell Phone Messaging

Remember to use this editorial

**only**when stuck, and**not to copy-paste code from it**. Please be respectful to the problem author and editorialist.**Submitting an official solution before solving the problem yourself is a bannable offence.**Author:

#### Subtask 1

If is the answer to the query , then the leftmost of Josh and Mike must be at .

Similarly, if is the answer to the query , then the rightmost of Josh and Mike must be at .

#### Subtask 2

If we query at and , we can use math to figure out which diagonals Josh and Mike are on.

Similarly, we query at and , we can figure out which anti-diagonals Josh and Mike are on.

There are at most two possible sets of positions for Josh and Mike, depending on which diagonal corresponds to which anti-diagonal. We can query at one of the candidate positions to determine the answer. Be careful not to query outside the grid.

## Comments