CF733E.Sleep in Class

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The academic year has just begun, but lessons and olympiads have already occupied all the free time. It is not a surprise that today Olga fell asleep on the Literature. She had a dream in which she was on a stairs.

The stairs consists of nn steps. The steps are numbered from bottom to top, it means that the lowest step has number 11 , and the highest step has number nn . Above each of them there is a pointer with the direction (up or down) Olga should move from this step. As soon as Olga goes to the next step, the direction of the pointer (above the step she leaves) changes. It means that the direction "up" changes to "down", the direction "down" — to the direction "up".

Olga always moves to the next step in the direction which is shown on the pointer above the step.

If Olga moves beyond the stairs, she will fall and wake up. Moving beyond the stairs is a moving down from the first step or moving up from the last one (it means the nn -th) step.

In one second Olga moves one step up or down according to the direction of the pointer which is located above the step on which Olga had been at the beginning of the second.

For each step find the duration of the dream if Olga was at this step at the beginning of the dream.

Olga's fall also takes one second, so if she was on the first step and went down, she would wake up in the next second.

输入格式

The first line contains single integer nn ( 1<=n<=1061<=n<=10^{6} ) — the number of steps on the stairs.

The second line contains a string ss with the length nn — it denotes the initial direction of pointers on the stairs. The ii -th character of string ss denotes the direction of the pointer above ii -th step, and is either 'U' (it means that this pointer is directed up), or 'D' (it means this pointed is directed down).

The pointers are given in order from bottom to top.

输出格式

Print nn numbers, the ii -th of which is equal either to the duration of Olga's dream or to 1-1 if Olga never goes beyond the stairs, if in the beginning of sleep she was on the ii -th step.

输入输出样例

  • 输入#1

    3
    UUD
    

    输出#1

    5 6 3 
  • 输入#2

    10
    UUDUDUUDDU
    

    输出#2

    5 12 23 34 36 27 18 11 6 1 
首页