Bellovin

TimeLimit:3000MS  MemoryLimit:131072KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Peter has a sequence $a_1,a_2,...,a_n$ and he define a function on the sequence -- $F(a_1,a_2,...,a_n)=(f_1,f_2,...,f_n)$, where $f_i$ is the length of the longest increasing subsequence ending with $a_i$.

Peter would like to find another sequence $b_1,b_2,...,b_n$ in such a manner that $F(a_1,a_2,...,a_n)$ equals to $F(b_1,b_2,...,b_n)$. Among all the possible sequences consisting of only positive integers, Peter wants the lexicographically smallest one.

The sequence $a_1, a_2, ..., a_n$ is lexicographically smaller than sequence $b_1, b_2, ..., b_n$, if there is such number $i$ from $1$ to $n$, that $a_k = b_k$ for $1 \le k < i$ and $a_i < b_i$.
Input
There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:

The first contains an integer $n$ $(1 \le n \le 100000)$ -- the length of the sequence. The second line contains $n$ integers $a_1,a_2,...,a_n$ $(1 \le a_i \le 10^9)$.
Output
For each test case, output $n$ integers $b_1,b_2,...,b_n$ $(1 \le b_i \le 10^9)$ denoting the lexicographically smallest sequence.
SampleInput
3
1
10
5
5 4 3 2 1
3
1 3 5
SampleOutput
1
1 1 1 1 1
1 2 3
Submit
题目统计信息详细
总AC数3
通过人数3
尝试人数4
总提交量4
AC率75.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: