F - Teleporter Takahashi Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 500500

問題文

xyxy 平面上に高橋くんがいます。 はじめ、高橋くんは点 (sx,sy)(s _ x,s _ y) にいます。 高橋くんは、点 (tx,ty)(t _ x,t _ y) に移動したいです。

xyxy 平面上に、長方形 R{(x,y)a0.5xb+0.5,c0.5yd+0.5}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 があります。 次の操作を考えます。

  • 長方形 RR に含まれる格子点 (x,y)(x,y) をひとつ選ぶ。 点 (x,y)(x,y) を中心に高橋くんはいまいる位置と対称な位置に瞬間移動する。

上の操作を 00 回以上 10610^6 回以下繰り返して、高橋くんが点 (tx,ty)(t _ x,t _ y) にいるようにできるか判定してください。 できる場合、高橋くんが点 (tx,ty)(t _ x,t _ y) に移動することができるような操作の列を 11 つ構成してください。

制約

  • 0sx,sy,tx,ty2×1050\leq s _ x,s _ y,t _ x,t _ y\leq2\times10^5
  • 0ab2×1050\leq a\leq b\leq2\times10^5
  • 0cd2×1050\leq c\leq d\leq2\times10^5
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

sxs _ x sys _ y
txt _ x tyt _ y
aa bb cc dd

出力

11 行目には、操作を 00 回以上 10610^6 回以下繰り返して高橋くんが点 (tx,ty)(t _ x,t _ y) に到達できるなら Yes 、そうでなければ No と出力せよ。 11 行目で Yes と出力したとき、かつそのときに限り、あなたが構成した操作列の長さを dd としてさらに dd 行出力せよ(dd0d1060\leq d\leq10^6 を満たさなければならない)。 1+i1+i 行目 (1id)(1\leq i\leq d) には、ii 回目の操作で選んだ点 (x,y)R(x, y)\in R の座標をこの順に空白区切りで出力せよ。


入力例 1Copy

Copy
1 2
7 8
7 9 0 3

出力例 1Copy

Copy
Yes
7 0
9 3
7 1
8 1

例えば、次のようにして (1,2)(1,2) から (7,8)(7,8) へ移動することができます。

  • (7,0)(7,0) を選ぶ。高橋くんは (13,2)(13,-2) に移動する。
  • (9,3)(9,3) を選ぶ。高橋くんは (5,8)(5,8) に移動する。
  • (7,1)(7,1) を選ぶ。高橋くんは (9,6)(9,-6) に移動する。
  • (8,1)(8,1) を選ぶ。高橋くんは (7,8)(7,8) に移動する。

条件を満たす操作の列であれば何を出力しても正答となるので、例えば

Yes
7 3
9 0
7 2
9 1
8 1

と出力しても正答となります。


入力例 2Copy

Copy
0 0
8 4
5 5 0 0

出力例 2Copy

Copy
No

どのように操作しても点 (8,4)(8,4) に移動することはできません。


入力例 3Copy

Copy
1 4
1 4
100 200 300 400

出力例 3Copy

Copy
Yes

高橋くんがはじめから目的地にいる場合もあります。


入力例 4Copy

Copy
22 2
16 7
14 30 11 14

出力例 4Copy

Copy
No

Score : 500500 points

Problem Statement

Takahashi is on an xyxy-plane. Initially, he is at point (sx,sy)(s _ x,s _ y), and he wants to reach point (tx,ty)(t _ x,t _ y).

On the xyxy-plane is a rectangle R{(x,y)a0.5xb+0.5,c0.5yd+0.5}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 (x,y)(x,y) contained in the rectangle RR. Takahashi teleports to the point symmetric to his current position with respect to point (x,y)(x,y).

Determine if he can reach point (tx,ty)(t _ x,t _ y) after repeating the operation above between 00 and 10610^6 times, inclusive. If it is possible, construct a sequence of operations that leads him to point (tx,ty)(t _ x,t _ y).

Constraints

  • 0sx,sy,tx,ty2×1050\leq s _ x,s _ y,t _ x,t _ y\leq2\times10^5
  • 0ab2×1050\leq a\leq b\leq2\times10^5
  • 0cd2×1050\leq c\leq d\leq2\times10^5
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

sxs _ x sys _ y
txt _ x tyt _ y
aa bb cc dd

Output

In the first line, print Yes if Takahashi can reach point (tx,ty)(t _ x,t _ y) after repeating the operation between 00 and 10610^6 times, inclusive, and No otherwise. If and only if you print Yes in the first line, print dd more lines, where dd is the length of the sequence of operations you have constructed (dd must satisfy 0d1060\leq d\leq10^6). The (1+i)(1+i)-th line (1id)(1\leq i\leq d) should contain the space-separated coordinates of the point (x,y)R(x, y)\in R, in this order, that is chosen in the ii-th operation.


Sample Input 1Copy

Copy
1 2
7 8
7 9 0 3

Sample Output 1Copy

Copy
Yes
7 0
9 3
7 1
8 1

For example, the following choices lead him from (1,2)(1,2) to (7,8)(7,8).

  • Choose (7,0)(7,0). Takahashi moves to (13,2)(13,-2).
  • Choose (9,3)(9,3). Takahashi moves to (5,8)(5,8).
  • Choose (7,1)(7,1). Takahashi moves to (9,6)(9,-6).
  • Choose (8,1)(8,1). Takahashi moves to (7,8)(7,8).

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.


Sample Input 2Copy

Copy
0 0
8 4
5 5 0 0

Sample Output 2Copy

Copy
No

No sequence of operations leads him to point (8,4)(8,4).


Sample Input 3Copy

Copy
1 4
1 4
100 200 300 400

Sample Output 3Copy

Copy
Yes

Takahashi may already be at the destination in the beginning.


Sample Input 4Copy

Copy
22 2
16 7
14 30 11 14

Sample Output 4Copy

Copy
No


2025-04-14 (Mon)
13:57:17 +00:00