

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
長さ の整数列 が与えられます。
について、 が の最長増加部分列に含まれることがあるか判定してください。
が の最長増加部分列に含まれることがあるとは、以下のことをいいます。
-
最長増加部分列の長さを とする。各要素が 以上 以下の単調増加な整数列 であって以下をすべて満たすものが存在する。
- ある が存在して である
個のテストケースが与えられるので、それぞれについて答えを求めてください。
最長増加部分列とは?
列 の部分列とは の要素をいくつか抜き出して元の順に並べてできる列を指します。
列 の最長増加部分列とは、 の狭義単調増加な部分列のうち列の長さが最大のものを指します。
制約
- 全てのテストケースにおける の総和は 以下
入力
入力は以下の形式で標準入力から与えられる。
ここで は 番目のケースの入力を意味する。各ケースは以下の形式で与えられる。
出力
以下の形式で出力せよ。
ここで は 番目のケースの出力を意味する。各ケースについては、次の通りである。
が の最長増加部分列に含まれることがある が 個存在し、昇順に であったとする。このとき、以下の形式で出力せよ。
入力例 1Copy
1 5 2 1 4 5 3
出力例 1Copy
4 1 2 3 4
最長増加部分列の つは で、長さは です。 も最長増加部分列の つです。しかし、 を含む最長増加部分列はありません。
よって、 を出力します。
入力例 2Copy
2 6 2 5 3 4 3 4 5 10000 1000 100 1 10
出力例 2Copy
5 1 3 4 5 6 2 4 5
Score : points
Problem Statement
You are given an integer sequence of length .
For each , determine whether is included in a longest increasing subsequence of .
Here, is included in a longest increasing subsequence of if and only if the following holds:
-
Let be the length of a longest increasing subsequence of . There exists a strictly increasing integer sequence , where each element is between and , inclusive, that satisfies all of the following conditions:
- .
- for some .
You are given test cases; solve each of them.
What is a longest increasing subsequence?
A subsequence of a sequence is a sequence that can be derived by extracting some elements from without changing the order.
A longest increasing subsequence of a sequence is a subsequence of that is strictly increasing with the greatest possible length.
Constraints
- The sum of across all test cases is at most .
Input
The input is given from Standard Input in the following format:
Here, represents the input for the -th case. Each case is given in the following format:
Output
Print the answers in the following format:
Here, represents the output for the -th case. For each case, let there be indices such that is included in a longest increasing subsequence of , which are in ascending order. Print these in the following format:
Sample Input 1Copy
1 5 2 1 4 5 3
Sample Output 1Copy
4 1 2 3 4
One of the longest increasing subsequences is , with a length of . Another longest increasing subsequence is . However, no longest increasing subsequence includes .
Therefore, print .
Sample Input 2Copy
2 6 2 5 3 4 3 4 5 10000 1000 100 1 10
Sample Output 2Copy
5 1 3 4 5 6 2 4 5