Codeforces Round 673 (Div. 1)
A
k-Amazing Numbers
Codeforces
1500
原题
←B →
翻译中…

You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.

翻译中…

Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ elements). If there is no integer occuring in all subsegments of length $k$ for some value of $k$, then the $k$-amazing number is $-1$.

翻译中…

For each $k$ from $1$ to $n$ calculate the $k$-amazing number of the array $a$.

翻译中…

Input

翻译中…

The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases. Then $t$ test cases follow.

翻译中…

The first line of each test case contains one integer $n$ ($1 \le n \le 3 \cdot 10^5$) — the number of elements in the array. The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$) — the elements of the array.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $3 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case print $n$ integers, where the $i$-th integer is equal to the $i$-amazing number of the array.

翻译中…

样例

Input #1
3
5
1 2 3 4 5
5
4 4 4 4 2
6
1 3 1 5 3 1
Output #1
-1 -1 3 2 1
-1 4 4 4 2
-1 -1 1 1 1 1
InputCopy OutputCopy
题目信息
题号
1416A
时间限制
1 s
内存限制
256 MB
标签
二分
数据结构
模拟
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。