Codeforces Round 620 (Div. 2)
D
Shortest and Longest LIS
Codeforces
1800
原题
← CE →
翻译中…

Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to make a quiz for you about making permutations of $n$ distinct integers between $1$ and $n$, inclusive, to test his code with your output.

翻译中…

The quiz is as follows.

翻译中…

Gildong provides a string of length $n-1$, consisting of characters '<' and '>' only. The $i$-th (1-indexed) character is the comparison result between the $i$-th element and the $i+1$-st element of the sequence. If the $i$-th character of the string is '<', then the $i$-th element of the sequence is less than the $i+1$-st element. If the $i$-th character of the string is '>', then the $i$-th element of the sequence is greater than the $i+1$-st element.

翻译中…

He wants you to find two possible sequences (not necessarily distinct) consisting of $n$ distinct integers between $1$ and $n$, inclusive, each satisfying the comparison results, where the length of the LIS of the first sequence is minimum possible, and the length of the LIS of the second sequence is maximum possible.

翻译中…

Input

翻译中…

Each test contains one or more test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$).

翻译中…

Each test case contains exactly one line, consisting of an integer and a string consisting of characters '<' and '>' only. The integer is $n$ ($2 \le n \le 2 \cdot 10^5$), the length of the permutation you need to find. The string is the comparison results explained in the description. The length of the string is $n-1$.

翻译中…

It is guaranteed that the sum of all $n$ in all test cases doesn't exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, print two lines with $n$ integers each. The first line is the sequence with the minimum length of the LIS, and the second line is the sequence with the maximum length of the LIS. If there are multiple answers, print any one of them. Each sequence should contain all integers between $1$ and $n$, inclusive, and should satisfy the comparison results.

翻译中…

It can be shown that at least one answer always exists.

翻译中…

Note

翻译中…

In the first case, $1$ $2$ $3$ is the only possible answer.

翻译中…

In the second case, the shortest length of the LIS is $2$, and the longest length of the LIS is $3$. In the example of the maximum LIS sequence, $4$ '$3$' $1$ $7$ '$5$' $2$ '$6$' can be one of the possible LIS.

翻译中…

样例

Input #1
3
3 <<
7 >><>><
5 >>><
Output #1
1 2 3
1 2 3
5 4 3 7 2 1 6
4 3 1 7 5 2 6
4 3 2 1 5
5 4 2 1 3
InputCopy OutputCopy
题目信息
题号
1304D
时间限制
3 s
内存限制
256 MB
标签
构造
图论
贪心
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。