問題一覧 > 通常問題

No.3466 Mex Ranges

レベル : / AI推定難易度 : 2100 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 11
作問者 : dyktr_06 / テスター : tyawanmusi sepa38 hikikomori
お気に入りにしたユーザー ProblemId : 12941 / 自分の提出
問題文最終更新日: 2025-12-18 04:06:06
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
MMA Contest 021 (順位表) の他の問題:

Problem Statement

You are given a sequence $A$ of non-negative integers of length $N$.

For each of $k = 0, 1, 2, \cdots, N$, solve the following problem.

  • Find the number of pairs of integers $(l, r)$ satisfying $1 \leq l \leq r \leq N$ such that $\text{mex}(A_l, A_{l + 1}, \cdots, A_r) = k$.
Here, $\text{mex}(x_1, x_2, \cdots, x_{p})$ is defined as the smallest non-negative integer not contained in $x_1, x_2, \cdots, x_{p}$.

Constraints

  • $1 \leq N \leq 2 \times 10^{5}$
  • $0 \leq A_{i} \leq 10^{9}$
  • All input values are integers.

Input

The input is given from standard input in the following format.

$N$
$A_1$ $A_2$ $\cdots$ $A_N$

Output

Print $N + 1$ lines.

On the $i$-th line, print the answer for $k = i - 1$.

Sample

Sample 1
Input
5
0 3 8 1 2
Output
10
3
1
0
1
0

For example, for $k = 1$, the pairs $(1, 1), (1, 2), (1, 3)$ satisfy the condition.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。