丸紅プログラミングコンテスト2024(AtCoder Regular Contest 183)
B
Near Assignment
AtCoder
⌀ 2118
原题
← AC →
翻译中…

Problem Statement

翻译中…

You are given integer sequences of length $N$: $A=(A_1,A_2,\cdots,A_N)$ and $B=(B_1,B_2,\cdots,B_N)$, and an integer $K$.

翻译中…

You can perform the following operation zero or more times.

翻译中…
  • Choose integers $i$ and $j$ ($1 \leq i,j \leq N$). Here, $|i-j| \leq K$ must hold. Then, change the value of $A_i$ to $A_j$.
翻译中…

Determine whether it is possible to make $A$ identical to $B$.

翻译中…

There are $T$ test cases for each input.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 125000$
  • $1 \leq K < N \leq 250000$
  • $1 \leq A_i,B_i \leq N$
  • The sum of $N$ across all test cases in each input is at most $250000$.
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

T
case_1
case_2
\vdots
case_T

翻译中…

Each test case is given in the following format:

翻译中…

N K
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_N

翻译中…

Output

翻译中…

For each test case, print Yes if it is possible to make $A$ identical to $B$, and No otherwise.

翻译中…

样例

Input #1
4
3 1
1 1 2
1 2 2
5 4
2 4 5 1 3
2 1 3 2 2
13 1
3 1 3 3 5 3 3 4 2 2 2 5 1
5 3 3 3 4 2 2 2 2 5 5 1 3
20 14
10 6 6 19 13 16 15 15 2 10 2 16 9 12 2 6 13 5 5 9
5 9 6 2 10 19 16 15 13 12 10 2 9 6 5 16 19 12 15 13
Output #1
Yes
Yes
No
Yes
Consider the first test case. If we operate with $i=2$ and $j=3$, the value of $A_2$ will be changed to $A_3=2$, resulting in $A=(1,2,2)$.
题目信息
题号
arc183_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。