QOJ.ac

QOJ

حد الوقت: 11 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#13978. 赛马 - 困难

الإحصائيات

你正在与你的宿敌进行一场赛马比赛。你和你的宿敌各有 $N$ 匹马。这场比赛共有 $N$ 轮,在每一轮中,你的一匹马将与你宿敌的一匹马进行比赛。所有的马都只参赛一次。

你拥有的 $N$ 匹马目前排成一排。这一排中的第 $i$ 匹马的速度为 $a_i$。

你的宿敌也派出了 $N$ 匹马。他们的每匹马的速度为 $b_i$。速度较高的马总是会赢得比赛。没有两匹马的速度是相同的。

你确切地知道你的宿敌派出马的顺序,即按照 $b_0, b_1, b_2, \dots, b_{N-1}$ 的顺序。由于你的马目前排成一排,重新排列它们会花费太多精力。相反,你可以选择你马匹的任意一种循环移位,并按照该顺序派出它们。我们定义第 $i$($0 \le i \le N - 1$)次循环移位为第 $i$ 次右循环移位,即在原始顺序中,最后的 $i$ 匹马被移动到最前面。

如果你选择的顺序能让你赢得严格多于一半的单场比赛,你就赢得了整场比赛。输出所有能让你赢得比赛的循环移位!

输入格式

第一行包含一个整数 $N$($1 \le N \le 200\,000$),表示比赛的轮数。

第二行包含 $N$ 个空格分隔的整数,其中第 $i$ 个整数表示 $a_i$($1 \le a_i \le 10^9$),即你队伍中第 $i$ 匹马的速度。

第三行包含 $N$ 个空格分隔的整数,其中第 $i$ 个整数表示 $b_i$($1 \le b_i \le 10^9$),即你宿敌派出马匹顺序中第 $i$ 匹马的速度。所有的 $a_i$ 和 $b_i$ 的值互不相同。

输出格式

第一行输出一个整数,表示能赢得比赛的循环移位数量。

接下来的一行中,按升序输出所有能赢得比赛的循环移位编号,用空格分隔。如果没有这样的循环移位,请输出一个空行。

样例

输入样例 1

3
7 10 4
1 6 9

输出样例 1

2
0 1

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.