CF1365F Swaps Again

题目描述

给出两个长度为 $n$ 的数列 $a,b$,你需要判断能否在数次操作后使得 $a$ 与 $b$ 相同。 操作是指你可以选择一个 $k(1\le k\le\lfloor\frac n2\rfloor)$,之后交换 $a$ 的长度为 $k$ 的前缀和长度为 $k$ 的后缀。 例如对于 $a=\{1,2,3,4,5,6\}$,选择 $k=2$,那么交换后会得到 $\{5,6,3,4,1,2\}$。

输入格式

**本题有多组数据** 第一行一个整数 $T$,表示数据组数。 每组数据的第一行有一个整数 $n$,表示数列长度。 之后一行 $n$ 个整数,表示 $a$。 之后一行 $n$ 个整数,表示 $b$。 保证 $1\le T\le500$,$1\le n\le500$,$1\le a_i,b_i\le10^9$。

输出格式

对每组数据输出 `yes` 或 `no`,大小写不敏感。

说明/提示

For the first test case, we can swap prefix $ a[1:1] $ with suffix $ a[2:2] $ to get $ a=[2, 1] $ . For the second test case, $ a $ is already equal to $ b $ . For the third test case, it is impossible since we cannot obtain $ 3 $ in $ a $ . For the fourth test case, we can first swap prefix $ a[1:1] $ with suffix $ a[4:4] $ to obtain $ a=[2, 2, 3, 1] $ . Now we can swap prefix $ a[1:2] $ with suffix $ a[3:4] $ to obtain $ a=[3, 1, 2, 2] $ . For the fifth test case, it is impossible to convert $ a $ to $ b $ .