F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Bellovin

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2841    Accepted Submission(s): 1086


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.
 

Sample Input
3 1 10 5 5 4 3 2 1 3 1 3 5
 

Sample Output
1 1 1 1 1 1 1 2 3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 10:02:00, Gzip enabled