Description :
Gildong recently learned how to find the longest increasing subsequence (LIS) in O(nlogn) 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 and , inclusive, to test his code with your output.
The quiz is as follows.
Gildong provides a string of length , consisting of characters and only. The i-th (1-indexed) character is the comparison result between the i-th element and the element of the sequence. If the character of the string is ‘<’, then the i-th element of the sequence is less than the element. If the character of the string is , then the element of the sequence is greater than the
He wants you to find two possible sequences (not necessarily distinct) consisting of n distinct integers between and , 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
Each test case contains exactly one line, consisting of an integer and a string consisting of characters and only. The integer is , 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 .
It is guaranteed that the sum of all n in all test cases doesn’t exceed .
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 and , inclusive, and should satisfy the comparison results.
It can be shown that at least one answer always exists.
Example
inputCopy
3
3 <<
7 >><>><
5 >>><
outputCopy
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
Note
In the first case,
In the second case, the shortest length of the LIS is , and the longest length of the LIS is . In the example of the maximum LIS sequence,
题意:
给你一个表示大小关系的序列,序列里只包含 和 ,它表示的是一个序列里相邻的数字的大小关系。题目让你找出符合这个大小关系同时有着最短的“最长上升子序列”的序列,和符合这个大小关系同时有着最长的“最长上升子序列”的序列。
贪心来做,第一个序列先放大的,第二个序列放小的,比如 如果找最大的序列,就先放 ,碰见小于号就让当前的值加 ,如果是大于号,找到 这个位置,然后从这个地方贪心的放,
AC代码: