CF1032G.Chattering

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There are nn parrots standing in a circle. Each parrot has a certain level of respect among other parrots, namely rir_i. When a parrot with respect level xx starts chattering, xx neighbours to the right and to the left of it start repeating the same words in 1 second. Their neighbours then start repeating as well, and so on, until all the birds begin to chatter.

You are given the respect levels of all parrots. For each parrot answer a question: if this certain parrot starts chattering, how many seconds will pass until all other birds will start repeating it?

有 nn 只鹦鹉围成一个圆圈站立。每只鹦鹉在其他鹦鹉中具有一定的受尊敬程度,记为 rir_i。当一只受尊敬程度为 xx 的鹦鹉开始聒噪时,它左右两侧各 xx 只邻居将在 1 秒后开始重复相同的词语。接着,这些邻居的邻居也将在下一秒开始重复,依此类推,直到所有鹦鹉都开始聒噪。

给定所有鹦鹉的受尊敬程度。对每只鹦鹉回答如下问题:若该鹦鹉率先开始聒噪,则需经过多少秒,其余所有鹦鹉才会开始重复它的话语?

输入格式

In the first line of input there is a single integer nn, the number of parrots (1≤n≤1051 \leq n \leq 10^5).

In the next line of input there are nn integers r1r_1, ..., rnr_n, the respect levels of parrots in order they stand in the circle (1≤ri≤n1 \leq r_i \leq n).

输入的第一行包含一个整数 nn,表示鹦鹉的数量(1≤n≤1051 \leq n \leq 10^5)。

输入的第二行包含 nn 个整数 r1r_1, ..., rnr_n,表示按顺时针方向围成一圈的鹦鹉的尊重度(1≤ri≤n1 \leq r_i \leq n)。

输出格式

Print nn integers. ii-th of them should equal the number of seconds that is needed for all parrots to start chattering if the ii-th parrot is the first to start.

输出 nn 个整数。其中第 ii 个整数应等于:若第 ii 只鹦鹉最先开始鸣叫,则所有鹦鹉都开始鸣叫所需的秒数。

输入输出样例

  • 输入#1

    4
    1 1 4 1

    输出#1

    2 2 1 2
  • 输入#2

    8
    1 2 2 1 5 1 3 1

    输出#2

    3 3 2 2 1 2 2 3

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

首页