CF1501B.Napoleon Cake

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can't make a problem about stacking pancakes without working at a specific IT company, so he decided to bake the Napoleon cake instead.

To bake a Napoleon cake, one has to bake nn dry layers first, and then put them on each other in one stack, adding some cream. Arkady started with an empty plate, and performed the following steps nn times:

  • place a new cake layer on the top of the stack;
  • after the ii-th layer is placed, pour aia_i units of cream on top of the stack.

When xx units of cream are poured on the top of the stack, top xx layers of the cake get drenched in the cream. If there are less than xx layers, all layers get drenched and the rest of the cream is wasted. If x=0x = 0, no layer gets drenched.

The picture represents the first test case of the example.

Help Arkady determine which layers of the cake eventually get drenched when the process is over, and which don't.

本周,阿尔卡季想做一些煎饼(遵循古老的传统),并为此出一道编程题。但随后他想起,如果不曾在某家特定的IT公司工作,就无法出一道关于堆叠煎饼的题目,于是他决定改为制作拿破仑蛋糕。

制作拿破仑蛋糕,首先需烘烤 nn 层干饼皮,然后将它们叠成一摞,并在各层之间添加奶油。阿尔卡季从一个空盘子开始,重复以下步骤 nn 次:

  • 将一层新饼皮放在当前堆叠的最上方;
  • 在第 ii 层放置完毕后,向堆叠顶部倾倒 aia_i 单位的奶油。

当向堆叠顶部倾倒 xx 单位奶油时,堆叠最上方的 xx 层饼皮会被浸透。若堆叠层数少于 xx,则所有层均被浸透,多余的奶油被浪费。若 x=0x = 0,则没有任何一层被浸透。

该图表示示例中的第一个测试用例。

请帮助阿尔卡季判断:整个过程结束后,蛋糕的哪些层最终被浸透,哪些没有被浸透。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤20 0001 \le t \le 20\,000). Description of the test cases follows.

The first line of each test case contains a single integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of layers in the cake.

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤n0 \le a_i \le n) — the amount of cream poured on the cake after adding each layer.

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

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤20 0001 \le t \le 20\,000)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 蛋糕的层数。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤n0 \le a_i \le n)—— 在添加每一层后浇在蛋糕上的奶油量。

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

输出格式

For each test case, print a single line with nn integers. The ii-th of the integers should be equal to 11 if the ii-th layer from the bottom gets drenched, and 00 otherwise.

对于每个测试用例,输出一行包含 nn 个整数。其中第 ii 个整数应为 11,当且仅当从底部数起的第 ii 层被浸湿;否则为 00。

输入输出样例

  • 输入#1

    3
    6
    0 3 0 0 1 3
    10
    0 0 0 1 0 5 0 0 0 2
    3
    0 0 0

    输出#1

    1 1 0 1 1 1 
    0 1 1 1 1 1 0 0 1 1 
    0 0 0

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

首页