QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100

#7805. 跳跃的青蛙

Statistiques

Julia 是一位野生动物摄影爱好者。昨天,她拍摄了两张关于一条美丽的河流的照片,河里有一些睡莲,上面坐着一些青蛙。

河里有许多睡莲,从左到右依次编号为正整数,从 1 开始。两张照片都是在完全相同的位置拍摄的,并且两张照片中都有 $n$ 只青蛙坐在睡莲上。每片睡莲最多只能坐一只青蛙。

对比照片后,Julia 发现所有的青蛙在两张照片之间都移动了位置,因为没有任何一片睡莲在两张照片中都有青蛙。然而,Julia 无法弄清楚第一张照片中的哪只青蛙移动到了第二张照片中的哪片睡莲上,因为所有的青蛙看起来都一模一样!

可以确定的是:每只青蛙都跳到了不同的睡莲上。一些青蛙向左移动,跳到了编号较小的睡莲上,而其他青蛙则向右移动,跳到了编号较大的睡莲上。

为了研究青蛙的移动情况,Julia 想要回答以下问题:在两张照片之间,有多少只青蛙向左移动了?由于这个问题可能没有唯一的答案,你需要帮助 Julia 找出所有可能的答案。

输入格式

第一行包含一个整数 $n$,表示青蛙的数量 ($1 \le n \le 200\,000$)。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$,表示第一张照片中青蛙所在的睡莲编号,按递增顺序排列 ($1 \le a_1 < a_2 < \dots < a_n \le 10^9$)。

第三行包含 $n$ 个整数 $b_1, b_2, \dots, b_n$,表示第二张照片中青蛙所在的睡莲编号,按递增顺序排列 ($1 \le b_1 < b_2 < \dots < b_n \le 10^9$)。

所有 $2n$ 个给定的整数互不相同:没有任何一片睡莲在两张照片中都有青蛙。

输出格式

第一行输出一个整数 $k$,表示 Julia 的问题有多少种可能的答案。

第二行输出 $k$ 个整数 $c_1, c_2, \dots, c_k$,表示所有可能的答案,按递增顺序排列 ($0 \le c_1 < c_2 < \dots < c_k \le n$)。

样例

输入 1

4
10 20 30 40
1 2 51 52

输出 1

1
2

输入 2

4
10 20 30 40
5 15 25 35

输出 2

4
1 2 3 4

输入 3

1
100
200

输出 3

1
0

说明

在第一个样例中,最终停在睡莲 1 和 2 上的青蛙一定向左移动了,而停在睡莲 51 和 52 上的青蛙一定向右移动了。因此,我们确定恰好有 2 只青蛙在两张照片之间向左移动了。

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.