QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#18690. 排列压缩 II

Estadísticas

对于一个数组中的元素,如果它非零严格大于它之前的所有元素,则称其为漂亮元素。数组的漂亮度定义为数组中漂亮元素的个数。

给定一个长度为 $n$ 的排列。你可以通过将某些漂亮元素变为零来最大化其漂亮度。注意,在操作之后,某些元素可能变得漂亮,并且会成为你后续操作的目标。

由于修改数组很累,你决定在使用最少操作数的前提下最大化数组的漂亮度。

如果有多种方案,输出任意一种。

输入格式

包含多组测试数据。

第一行包含一个整数 $t$ ($1 \leq t \leq 10^6$),表示测试数据的组数。对于每组测试数据:

第一行包含一个整数 $n$ ($1 \leq n \leq 10^6$),表示排列的大小。

接下来一行包含 $n$ 个整数 $p_i$ ($1 \leq p_i \leq n$),表示排列中的元素。保证同一组测试数据中的所有 $p_i$ 互不相同。

保证 $\sum n \leq 10^6$。

输出格式

对于每组测试数据:

第一行包含两个整数 $b, c$,分别表示修改后数组的最大漂亮度和最少操作数。

第二行包含 $c$ 个整数 $o_i$,表示操作序列。操作 $o_i$ 表示将第 $o_i$ 个元素变为零。你需要确保在第 $i$ 次操作之前,第 $o_i$ 个元素是漂亮的。

如果有多种方案,输出任意一种。

样例

输入 1

2
3
3 1 2
3
1 2 3

输出 1

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