아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Pines

시간 제한1초메모리 제한1024 MB

요약
1부터 n+1까지의 높이를 한 줄로 배치해 A 램프의 양옆 비교 결과로 정해지는 빨강과 파랑 램프 수의 차이를 최소로 만든다.
난이도

보통10점 중 6점

유형
그리디, 수학, 구현
정답자
아직 제출이 없습니다

문제

In order to prepare for the celebration in the city P, it's been decided to decorate the alley. Two teams were hired for this, one is responsible for illuminating the alley, the other is responsible for planting the alley with pines.

Alley can be represented as a line. They decided to decorate it as follows --- starting with a pine tree, alternate between trees and lamps. As a result, n+1n + 1 pines will be planted on the alley and nn lamps will be installed.

Lamps were installed almost instantly, and they were of two types --- "A" and "B". "B"-type lamps always shine white light, color of "A"-type lamps on the other hand depends on its surroundings. If a tree standing to the left of the lamp is higher than a tree standing to the right of the lamp, then the lamp lights up red, otherwise it lights up blue.

When the pines have finally arrived it has turned out that all their heights are distinct and take values from 11 to n+1n + 1. It's been decided to arrange pines so that the number of red and the number of blue lamps were as close to each other as possible.

Help the team responsible for planting with arranging all n+1n + 1 pines so that the difference between the number of red lamps and the number of blue outs was minimal possible. Formally, if after the planting there are rr red and bb blue lamps, it's required to minimize the value of ∣r−b∣|r-b|.

입력

The first line of input contains one integer nn --- the total number of lamps (1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5).

The second line of input contains nn characters, ii-th equal to "A" or "B" - the type of ii-th lamp.

출력

Print n+1n + 1 unique numbers from 11 to n+1n + 1 --- heights of pines in the optimal placement. If there are several optimal answers, you can print any of them.

힌트

Illustration for the second sample test:

For clarity, red lamps in the illustration have a pentagon shape and blue lamps have a star shape.

Then r=1r = 1, b=1b = 1, ∣r−b∣=0|r - b| = 0 and this arrangement will be one of the most optimal.

예제2

  1. 예제 1

    입력
    2
    AA
    
    예상 출력
    1 3 2
    
  2. 예제 2

    입력
    4
    BABA
    
    예상 출력
    5 4 3 1 2