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

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

Rikka with String

시간 제한6초메모리 제한512 MB

요약
12개 소문자로 이루어진 문자열의 각 접미사마다, 12개 문자의 순열을 재배치해 그 접미사가 사전순으로 가장 큰 접미사가 될 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
문자열, 그리디, 정렬
정답자
아직 제출이 없습니다

문제

This is the last problem of this contest, so Rikka doesn't want to add a lengthy background to it. Let us make all the things simple and clear.

You have a string ss of length nn which only contains lowercase English letters from "a" to "l" (there are 1212 possible letters). You can choose a permutation of these 1212 letters p_a,p_b,…,p_lp\_{\texttt{a}}, p\_{\texttt{b}}, \ldots, p\_{\texttt{l}}, and then consider the string t=p_s_1p_s_2…p_s_nt = p\_{s\_1} p\_{s\_2} \ldots p\_{s\_n}. Your task is to check for each ii from 11 to nn whether the ii-th suffix (the substring t\[i,n]t\[i, n]) can become the largest suffix of tt in lexicographical order after such modification.

입력

The first line contains a single integer tt (1≤t≤1031 \leq t \leq 10^3), the number of test cases.

Each test case is given on a separate line containing a string ss (1≤∣s∣≤1051 \leq |s| \leq 10^5, the string contains only lowercase English letters from "a" to "l").

It is guaranteed that there are at most 1515 test cases with ∣s∣>103|s| > 10^3.

출력

For each test case, output a single line with a binary string of length ∣s∣|s|. If the ii-th suffix can become the largest one, the ii-th position must contain "1". Otherwise, it must contain "0".

예제1

  1. 예제 1

    입력
    3
    abaab
    abcdefghijkllkjihgfedcba
    aabbcccbaabcca
    
    예상 출력
    01100
    111111111111011111111110
    10101000100000