시간 제한메모리 제한제출정답맞은 사람정답 비율
서브태스크 참고 (추가 시간 없음) 1024 MB (추가 메모리 없음)17151386.667%

문제

Your friend John just came back from vacation, and he would like to share with you a new property that he learned about strings.

John learned that a string C of length L consisting of uppercase English characters is strictly increasing if, for every pair of indices i and j such that 1 ≤ i < j ≤ L (1-based), the character at position i is smaller than the character at position j.

For example, the strings ABC and ADF are strictly increasing, however the strings ACC and FDA are not.

Now that he taught you this new exciting property, John decided to challenge you: given a string S of length N, you have to find out, for every position 1 ≤ i ≤ N, what is the length of the longest strictly increasing substring that ends at position ii.

입력

The first line of the input gives the number of test cases, T. T test cases follow.

Each test case consists of two lines.

The first line contains an integer N, representing the length of the string.

The second line contains a string S of length N, consisting of uppercase English characters.

출력

For each test case, output one line containing Case #x: y1 y2 ... yn, where x is the test case number (starting from 1) and yi is the length of the longest strictly increasing substring that ends at position i.

제한

  • 1 ≤ T ≤ 100.

Test Set 1 (5점)

시간 제한: 20 초

  • 1 ≤ N ≤ 100.

Test Set 2 (7점)

시간 제한: 40 초

  • 1 ≤ N ≤ 2 × 105.

예제 입력 1

2
4
ABBC
6
ABACDA

예제 출력 1

Case #1: 1 2 1 2
Case #2: 1 2 1 2 3 1

힌트

In Sample Case #1, the longest strictly increasing substring ending at position 1 is A. The longest strictly increasing substrings ending at positions 2, 3 and 4 are ABB and BC, respectively.

In Sample Case #2, the longest strictly increasing substrings for each position are AABAACACD and A.

채점 및 기타 정보

  • 예제는 채점하지 않는다.