307780: CF1416A. k-Amazing Numbers

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

k-Amazing Numbers

题意翻译

- 定义 一个序列的 $k$ 数 为 出现在序列所有长度为 $k$ 的子区间内的最小数,如没有数出现在所有长度为 $k$ 的子区间内,则 $k$ 数为 $-1$。 - 给出一个序列,求出对于 $k\in[1,n]$ 的每一个 $k$ 数。 - 数据组数 $t\le1000$,序列长度 $n\le3\times10^5$,元素大小 $1\le a_i\le n$。

题目描述

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 $ .

输入输出格式

输入格式


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 $ .

输出格式


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

输入输出样例

输入样例 #1

3
5
1 2 3 4 5
5
4 4 4 4 2
6
1 3 1 5 3 1

输出样例 #1

-1 -1 3 2 1 
-1 4 4 4 2 
-1 -1 1 1 1 1

Input

题意翻译

- 定义 一个序列的 $k$ 数 为 出现在序列所有长度为 $k$ 的子区间内的最小数,如没有数出现在所有长度为 $k$ 的子区间内,则 $k$ 数为 $-1$。 - 给出一个序列,求出对于 $k\in[1,n]$ 的每一个 $k$ 数。 - 数据组数 $t\le1000$,序列长度 $n\le3\times10^5$,元素大小 $1\le a_i\le n$。

加入题单

算法标签: