CF1416A.k-Amazing Numbers

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa consisting of nn integers numbered from 11 to nn.

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

For each kk from 11 to nn calculate the kk-amazing number of the array aa.

给你一个由 nn 个整数组成的数组 aa,这些整数编号从 11 到 nn。

我们定义数组的 kk-amazing 数为:在所有长度为 kk 的子段(注意:数组 aa 的长度为 kk 的子段是指 aa 中恰好包含 kk 个元素的一个连续部分)中均出现的最小整数。若对某个 kk 值,不存在在所有长度为 kk 的子段中均出现的整数,则该 kk-amazing 数为 −1-1。

请对每个从 11 到 nn 的 kk,计算数组 aa 的 kk-amazing 数。

输入格式

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

The first line of each test case contains one integer nn (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5) — the number of elements in the array. The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤n1 \le a_i \le n) — the elements of the array.

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

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 表示测试用例的数量。随后是 tt 个测试用例。

每个测试用例的第一行包含一个整数 nn(1≤n≤3⋅1051 \le n \le 3 \cdot 10^5)—— 表示数组中元素的个数。第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤n1 \le a_i \le n)—— 表示数组的元素。

保证所有测试用例的 nn 之和不超过 3⋅1053 \cdot 10^5。

输出格式

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

对于每个测试用例,输出 nn 个整数,其中第 ii 个整数等于该数组的第 ii-amazing 数。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页