2097. 套娃/Mexmex

我们定义一个集合的 mex\operatorname{mex} 是最小的不在 SS 中的非负整数。

给定一个序列 a1,,ana_1,\dots,a_n,对于每个 1kn1\leq k\leq n,我们按照如下方式定义 bkb_k

  • 对于 aa 的所有长为 kk 的子区间,求出这个子区间构成的数集的 mex\operatorname{mex}
  • 对于求出的所有 mex\operatorname{mex},求出这个数集自己的 mex\operatorname{mex},记为 bkb_k

请你求出序列 bb

We define mex\operatorname{mex} of a set SS to be the smallest non-negative integer not in SS.

Given a sequence a1,,ana_1,\dots,a_n, for each 1kn1\leq k\leq n, we define bkb_k as follows:

  • For all subintervals of aa of length kk, find the mex\operatorname{mex} of the set of numbers formed by this subinterval.
  • For all mex\operatorname{mex} found, find mex\operatorname{mex} of the set of numbers itself, denoted bkb_k.

Find the sequence bb.

输入

第一行输入一个正整数 nn1n1051\leq n\leq 10^5)。

第二行输入 nn 个整数 a1,,ana_1,\dots,a_n0ain0\leq a_i\leq n)。

The first line enters a positive integer nn (1n1051\leq n\leq 10^5).

The second line enters nn integers a1,,ana_1,\dots,a_n (0ain0\leq a_i\leq n).

输出

一行输出 nn 个整数 b1,,bnb_1,\dots,b_n

A line outputs nn integers b1,,bnb_1,\dots,b_n.

样例

标准输入 复制文本
6
0 0 0 1 2 3
标准输出 复制文本
2 3 4 0 0 0
登录以提交代码。
单点时限 1 秒
内存限制 512 MB
提交 6
通过 3