QOJ.ac

QOJ

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

#18690. Permutation Compression 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.