이진 문자열 S가 주어질 때, 두 문자열 s1(길이 p1)과 s2(길이 p2)의 반복을 교차시켜 S를 만들 수 있는 최소 p1 + p2를 구한다.
어려움8동적 계획법문자열완전 탐색구현면접 대비아직 제출이 없습니다시간 제한1초메모리 제한512 MBAn interleaved periodic string S can be written down using the following procedure:
To interleave two strings, merge their characters arbitrarily, maintaining the relative order in which they occur in both strings. For example, the strings “101” and “011” can be interleaved to get “011011” or “101011”, however they cannot be interleaved to form “110110”. Given S, find the minimum possible value of (p1 + p2).
The input consists of multiple test cases. The first line contains the number of test cases T. Each of the next T lines contain a string S consisting of only ‘0’s and ‘1’s.
Output T lines, one corresponding to each test case, containing the minimum value of (p1 + p2) for the corresponding test case.