A12016 | Chattering
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ parrots standing in a circle. Each parrot has a certain level of respect among other parrots, namely $r_i$ . When a parrot with respect level $x$ starts chattering, $x$ 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?
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?
输入格式
In the first line of input there is a single integer $n$ , the number of parrots ( $1 \leq n \leq 10^5$ ).
In the next line of input there are $n$ integers $r_1$ , ..., $r_n$ , the respect levels of parrots in order they stand in the circle ( $1 \leq r_i \leq n$ ).
In the next line of input there are $n$ integers $r_1$ , ..., $r_n$ , the respect levels of parrots in order they stand in the circle ( $1 \leq r_i \leq n$ ).
输出格式
Print $n$ integers. $i$ -th of them should equal the number of seconds that is needed for all parrots to start chattering if the $i$ -th parrot is the first to start.
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted