CF1936B.Pinball
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a one-dimensional grid of length n . The i -th cell of the grid contains a character si , which is either '<' or '>'.
When a pinball is placed on one of the cells, it moves according to the following rules:
- If the pinball is on the i -th cell and si is '<', the pinball moves one cell to the left in the next second. If si is '>', it moves one cell to the right.
- After the pinball has moved, the character si is inverted (i. e. if si used to be '<', it becomes '>', and vice versa).
- The pinball stops moving when it leaves the grid: either from the left border or from the right one.
You need to answer n independent queries. In the i -th query, a pinball will be placed on the i -th cell. Note that we always place a pinball on the initial grid.
For each query, calculate how many seconds it takes the pinball to leave the grid. It can be shown that the pinball will always leave the grid within a finite number of steps.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤105 ). The description of the test cases follows.
The first line of each test case contains an integer n ( 1≤n≤5⋅105 ).
The second line of each test case contains a string s1s2…sn of length n consisting of characters '<' and '>'.
It is guaranteed that the sum of n over all test cases does not exceed 5⋅105 .
输出格式
For each test case, for each i ( 1≤i≤n ) output the answer if a pinball is initially placed on the i -th cell.
输入输出样例
输入#1
3 3 ><< 4 <<<< 6 <><<<>
输出#1
3 6 5 1 2 3 4 1 4 7 10 8 1
说明/提示
In the first test case, the movement of the pinball for i=1 is shown in the following pictures. It takes the pinball 3 seconds to leave the grid.
The movement of the pinball for i=2 is shown in the following pictures. It takes the pinball 6 seconds to leave the grid.