P2215 [HAOI2007] Increasing Sequence

Description

Given a sequence $S=\{a_1,a_2,a_3,…,a_n\}$, if there exists $P=\{a_{x_1},a_{x_2},a_{x_3},…,a_{x_m}\}$ such that $(x_1

Input Format

- The first line contains an integer $N$, the number of elements in the sequence. - The second line contains $N$ integers: $a_1, a_2 , \cdots , a_n$. - The third line contains an integer $M$, the number of queries. Each of the next $M$ lines contains one integer $L$, asking for an increasing subsequence of length $L$.

Output Format

For each query: - If a valid subsequence exists, output the chosen subsequence’s elements $a_{x_1}, a_{x_2}, \dots, a_{x_L}$ on one line, separated by single spaces. - Otherwise, print `Impossible`.

Explanation/Hint

Constraints: $N \le 10000$, $M \le 1000$. The testdata are random. Translated by ChatGPT 5