QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 512 MB 总分: 100

#18041. Formally, You Choose Three Integers

统计

给定两个长度均为 $n$ 的数组 $a$ 和 $b$。

允许对 $a$ 进行零次或多次如下操作:

选择一个长度为偶数的连续子数组,并将其循环移动偶数个位置。形式化地,选择三个整数 $i, j$ 和 $k$($0 \le i < j < k \le n$,$j - i$ 是偶数,$k - i$ 是偶数),然后 $a$ 变为 $a_{0:i} + a_{j:k} + a_{i:j} + a_{k:n}$,其中 $a_{l:r}$ 表示 Python 切片。准确地说,它包含 0-based 索引中范围在 $[l, r)$ 内的元素,以及 1-based 索引中范围在 $(l, r]$ 内的元素。

是否可能将 $a$ 转换为 $b$?

输入格式

第一行包含一个整数 $n$($1 \le n \le 3 \cdot 10^5$),表示 $a$ 和 $b$ 的长度。

第二行包含 $n$ 个整数 $a_i$($1 \le a_i \le n$),表示 $a$ 的元素。

第三行包含 $n$ 个整数 $b_i$($1 \le b_i \le n$),表示 $b$ 的元素。

输出格式

如果可以将 $s$ 转换为 $t$,则输出 1,否则输出 0。

样例

输入样例 1

3
1 2 1
1 1 2

输出样例 1

0

输入样例 2

4
1 2 3 4
3 4 1 2

输出样例 2

1

输入样例 3

4
1 2 3 4
1 4 3 2

输出样例 3

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.