QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 512 MB Points totaux : 100

#1096. 最佳解法未知

Statistiques

你是名为 Best Solution Unknown (BSU) 的竞赛负责人。这场竞赛的规则简单但有些古怪。

首先,所有 $n$ 名参赛者排成一排。然后,进行 $n - 1$ 场比赛。在每场比赛中,评委会选择两名相邻的选手。被选中的选手会得到一个 NP-hard 问题,他们会尽力给出一个好的解。提供更好解的选手赢得比赛,另一名选手离开竞赛。之后,选手们重新排列成一行,因此离开竞赛的选手原本的相邻选手会与该轮的获胜者相邻。正如你所见,在所有 $n - 1$ 场比赛结束后,只剩下一名选手,该选手被宣布为竞赛的获胜者。

你非常了解参赛者,因此你知道比赛前每位选手的实力。从左往右数,第 $i$ 位选手的实力为 $a_i$。你还知道实力较强的选手会赢得比赛。如果选手的实力相等,则双方都有机会获胜。你注意到胜利会激励选手,因此比赛获胜者的实力会增加 $1$。

然而,你不知道每场比赛中是谁在对决,也不知道在实力相等的情况下谁会获胜。因此,你想知道谁有可能成为竞赛的获胜者。你认为这对 BSU 的参赛者来说是一个好问题,但不幸的是,它并不是 NP-hard 问题,所以你必须自己解决它。

输入格式

第一行包含一个整数 $n$,表示 BSU 的参赛人数 ($1 \le n \le 10^6$)。

第二行包含 $n$ 个整数 $a_i$,其中 $a_i$ 是第 $i$ 位选手的初始实力 ($1 \le a_i \le 10^9$)。

输出格式

第一行应包含一个整数 $k$,表示可能赢得竞赛的参赛者人数 ($1 \le k \le n$)。

第二行应包含 $k$ 个整数 $b_i$,按严格递增顺序排列,表示这些参赛者的编号 ($1 \le b_1 < b_2 < \dots < b_k \le n$)。

样例

样例输入 1

3
3 2 2

样例输出 1

3
1 2 3

样例输入 2

3
1 2 1

样例输出 2

1
2

样例输入 3

5
1 2 3 5 5

样例输出 3

3
3 4 5

样例输入 4

1
10

样例输出 4

1
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.