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

18256번 - Interleaved Periodic String 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB169816746.528%

문제

An interleaved periodic string S can be written down using the following procedure:

  1. Write down any two strings s1 and s2 of lengths p1 and p2 respectively. The strings must consist of only 0s and 1s, and can possibly be empty.
  2. Concatenate some copies of the string s1 to obtain string S1.
  3. Concatenate some copies of the string s2 to obtain string S2.
  4. Interleave the strings S1 and S2 to obtain S.

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.

제한

  • 1 ≤ T ≤ 20
  • 1 ≤ length of S ≤ 16

예제 입력 1

1
0101

예제 출력 1

2

힌트

출처

ICPC > Regionals > Asia West Continent > India > The 2009 ACM-ICPC Asia Amritapuri Regional Contest B번

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

출처

대학교 대회

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

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