题目描述
Problem Description
Given an integer sequence of length $N$, $A_1, \ldots, A_N$, and a positive integer $D$ between $1$ and $N$, consider the following operation:
- Choose integers $L, R$ and $X$ such that $1 \leq L \leq R \leq N$ and $R - L + 1 = D$, and simultaneously replace $A_L, A_{L+1}, \ldots, A_R$ with $(X - A_L), (X - A_{L+1}), \ldots, (X - A_R)$.
Determine if $A_1, A_2, \ldots, A_N$ can be made to match $B_1, B_2, \ldots, B_N$ through a finite number of operations. If possible, construct one such sequence of operations that satisfies all of the following conditions:
- The number of operations is at most $3 \times 10^5$ (it can be $0$).
- The absolute value of $X$ in each operation is at most $10^{13}$.
Under the constraints of this problem, it can be proven that if it is possible to match the sequences through a finite number of operations, then there exists a procedure that satisfies all the above conditions.
Input Format
The input is given from the standard input in the following format:
$N$ $D$ $A_1$ $A_2$ $\ldots$ $A_N$ $B_1$ $B_2$ $\ldots$ $B_N$
Output Format
If it is possible to match the sequences, output Yes. Otherwise, output No. If the answer is Yes, output the number of operations $K$ ($0 \leq K \leq 3 \times 10^5$) on the second line, and then output the operations in the following format for $K$ lines:
$L_1$ $R_1$ $X_1$ $\vdots$ $L_K$ $R_K$ $X_K$
Here, $L_i, R_i, X_i (1 \leq i \leq K)$ represent the values of $L, R, X$ for the $i$-th operation. If multiple solutions exist, any one of them can be output.
Sample Input and Output
Sample Input #1
4 2
1 2 3 4
4 4 3 3
Sample Output #1
Yes
3
1 2 5
3 4 7
2 3 7
Sample Input #2
2 2
1 2
1 3
Sample Output #2
No
Notes/Hints
Constraints
- All inputs are integers.
- $1 \leq D \leq N \leq 3 \times 10^5$
- $\lvert A_i \rvert \leq 10^6$
- $\lvert B_i \rvert \leq 10^6$
Partial Points
- Correctly solving the dataset where $1 \leq N \leq 3 \times 10^4$ will award $50$ points.
Sample Explanation 1
- From the initial state, performing the operation with $(L, R, X) = (1, 2, 5)$ changes the sequence to $[4, 3, 3, 4]$.
- Next, performing the operation with $(L, R, X) = (3, 4, 7)$ changes the sequence to $[4, 3, 4, 3]$.
- Finally, performing the operation with $(L, R, X) = (2, 3, 7)$ changes the sequence to $[4, 4, 3, 3]$, which matches $B$.
Sample Explanation 2
No matter what operations are performed, the sequences cannot be made to match.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分