Logo
(追記) (追記ここまで)

23495번 - Longest Lyndon Prefix 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB74322345.098%

문제

A word $w$ is a lyndon word if and only if it is strictly smaller than all its proper suffixes. For example, aab is a lyndon word, while aa is not a lyndon word.

Chiaki has a string $s_1s_2\dots s_n$ of length $n$. She would like to know $l_i,ドル that is the length of the longest prefix of $s_i s_{i + 1} \dots s_{n}$ which is a lyndon word.

입력

There are multiple test cases. The first line of the input contains an integer $T$ (1ドル \le T \le 10^5$), indicating the number of test cases. For each test case:

The first line contains an integer $n$ (1ドル \leq n \leq 10^5$). The second line contains a string $s_1 s_2 \dots s_n$ consists of lowercase characters.

The sum of all $n$ does not exceed 10ドル^5$.

출력

For each test case, output $n$ integers denoting $l_1, l_2, \dots, l_n$.

제한

예제 입력 1

3
3
aaa
3
aab
3
cba

예제 출력 1

1 1 1
3 2 1
1 1 1

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 18: Grand Prix of Bytedance I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /