QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 10

#8401. Ants

統計

On the number line, there are $n$ ants, with the $i$-th ant located at point $i$. Each ant is facing either to the right (in the direction of increasing coordinates) or to the left (in the direction of decreasing coordinates). The ants are small enough that we can treat them as single points.

Upon a signal, all ants start marching at the same unit speed in the directions they are facing. If two ants collide (reach the same point), they bounce off each other, meaning both change their direction of movement and continue marching. It can be proven that after some time, no more collisions will occur. Can you write a program that calculates how many times each ant will bounce off other ants?

Input

The first line of standard input contains a single integer $n$ ($1 \le n \le 300\,000$), representing the number of ants.

The second line of standard input contains a string of length $n$ consisting only of the characters 'L' and 'P'. If the $i$-th letter of this string is 'L', the $i$-th ant is initially facing left. Otherwise, if the letter is 'P', the ant is facing right.

Output

The only line of standard output should contain $n$ space-separated integers. The $i$-th of these numbers should be equal to the number of bounces of the $i$-th ant.

Examples

Input 1

6
LPPLPL

Output 1

0 1 3 3 2 1

Note

The first ant is initially facing left and will never bounce off any other ant. The last ant will collide with the fifth ant at point $5.5$, after which it will start marching to the right and will never stop. The third ant, after bouncing off the fourth at point $3.5$, will start moving to the left. The second ant will bounce off it at point $3$, after which it will turn left and never stop marching.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.