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

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

Shortest and Longest LIS

시간 제한3초메모리 제한256 MB

요약
1부터 n까지의 순열에서 인접 원소 사이의 '<', '>' 관계가 주어질 때, LIS 길이가 최소인 순열과 최대인 순열을 각각 하나씩 만든다.
난이도

보통10점 중 7점

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

문제

Gildong recently learned how to find the longest increasing subsequence (LIS) in O(nlog⁡n)O(n\log{n}) time for a sequence of length nn. 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 nn distinct integers between 11 and nn, inclusive, to test his code with your output.

The quiz is as follows.

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

He wants you to find two possible sequences (not necessarily distinct) consisting of nn distinct integers between 11 and nn, 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.

입력

Each test contains one or more test cases. The first line contains the number of test cases tt (1≤t≤1041 \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 nn (2≤n≤2⋅1052 \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−1n-1.

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

출력

For each test case, print two lines with nn 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 11 and nn, inclusive, and should satisfy the comparison results.

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

힌트

In the first case, 11 22 33 is the only possible answer.

In the second case, the shortest length of the LIS is 22, and the longest length of the LIS is 33. In the example of the maximum LIS sequence, 44 '33' 11 77 '55' 22 '66' can be one of the possible LIS.

예제1

  1. 예제 1

    입력
    3
    3 <<
    7 >><>><
    5 >>><
    
    예상 출력
    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