atcoder#ABC289F. [ABC289F] Teleporter Takahashi
[ABC289F] Teleporter Takahashi
Score : points
Problem Statement
Takahashi is on an -plane. Initially, he is at point , and he wants to reach point .
On the -plane is a rectangle $R\coloneqq\lbrace(x,y)\mid a-0.5\leq x\leq b+0.5,c-0.5\leq y\leq d+0.5\rbrace$. Consider the following operation:
- Choose a lattice point contained in the rectangle . Takahashi teleports to the point symmetric to his current position with respect to point .
Determine if he can reach point after repeating the operation above between and times, inclusive. If it is possible, construct a sequence of operations that leads him to point .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
In the first line, print Yes
if Takahashi can reach point after repeating the operation between and times, inclusive, and No
otherwise.
If and only if you print Yes
in the first line, print more lines, where is the length of the sequence of operations you have constructed ( must satisfy ).
The -th line should contain the space-separated coordinates of the point , in this order, that is chosen in the -th operation.
1 2
7 8
7 9 0 3
Yes
7 0
9 3
7 1
8 1
For example, the following choices lead him from to .
- Choose . Takahashi moves to .
- Choose . Takahashi moves to .
- Choose . Takahashi moves to .
- Choose . Takahashi moves to .
Any output that satisfies the conditions is accepted; for example, printing
Yes
7 3
9 0
7 2
9 1
8 1
is also accepted.
0 0
8 4
5 5 0 0
No
No sequence of operations leads him to point .
1 4
1 4
100 200 300 400
Yes
Takahashi may already be at the destination in the beginning.
22 2
16 7
14 30 11 14
No