1416A.md (1434B)
1 Source: https://codeforces.com/problemset/problem/1416/A 2 3 A. k-Amazing Numbers 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$. 22 23 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$. 24 25 For each $k$ from $1$ to $n$ calculate the $k$-amazing number of the array $a$. 26 27 Input 28 29 The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases. Then $t$ test cases follow. 30 31 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. 32 33 It is guaranteed that the sum of $n$ over all test cases does not exceed $3 \cdot 10^5$. 34 35 Output 36 37 For each test case print $n$ integers, where the $i$-th integer is equal to the $i$-amazing number of the array. 38 39 Example 40 41 Input 42 43 ``` 44 3 45 5 46 1 2 3 4 5 47 5 48 4 4 4 4 2 49 6 50 1 3 1 5 3 1 51 ``` 52 53 Output 54 55 ``` 56 -1 -1 3 2 1 57 -1 4 4 4 2 58 -1 -1 1 1 1 1 59 ```