Codeforces Round 1058 (Div. 2)
B
Distinct Elements
Codeforces
1100
原题
← AC →
翻译中…

Given an array $c$, let $f(c)$ be the number of distinct elements in $c$. For example, $f([1,2,2])=2$ because there are two distinct elements in $[1,2,2]$: $1$ and $2$. Also, define $c[i,j]$ as the subarray$^{\text{∗}}$ of $c$ bounded by positions $i$ and $j$ (that is, the array $[c_i,c_{i+1},\ldots,c_j]$).

翻译中…

There is an array $a$ of size $n$. An array $b$ of $n$ elements is constructed such that $b_i=f(a[1,i])+f(a[2,i])+\ldots+f(a[i,i])$. You are given the array $b$. Find any possible $a$ with elements $1 \leq a_i \leq n$. It is guaranteed that at least one possible $a$ exists.

翻译中…

$^{\text{∗}}$An array $x$ is a subarray of an array $y$ if $x$ can be obtained from $y$ by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^5$) – the number of elements in $a$ and $b$.

翻译中…

The second line of each test case contains $n$ integers $b_1,b_2,\ldots,b_n$ ($1 \leq b_i \leq 10^{18}$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, print any possible $a$ on a new line. The array $a$ should satisfy $1\leq a_i\leq n$.

翻译中…

For every test case, it is guaranteed at least one $a$ that satisfies the conditions exists.

翻译中…

Note

翻译中…

Let's verify our output for the second test case is correct:

翻译中…
  • $b_1=f([2])=1$
  • $b_2=f([2,3])+f([3])=2+1=3$
  • $b_3=f([2,3,2])+f([3,2])+f([2])=2+2+1=5$
翻译中…

样例

Input #1
4
3
1 3 6
3
1 3 5
3
1 3 4
4
1 2 3 7
Output #1
1 3 2
2 3 2
3 2 2
4 4 4 1
InputCopy OutputCopy
题目信息
题号
2160B
时间限制
1.5 s
内存限制
256 MB
标签
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。