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

3428번 - Casting Spells 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB419754517.647%

문제

Casting spells is the least understood technique of dealing with real life. Actually, people find it quite hard to distinguish between a real spells like “abrahellehhelleh” (used in the battles and taught at the mage universities) and screams like “rachelhellabracadabra” (used by uneducated witches for shouting at cats).

Finally, the research conducted at the Unheard University showed how one can measure the power of a word (be it a real spell or a scream). It appeared that it is connected with the mages’ ability to pronounce words backwards. (Actually, some singers were burned at the stake for exactly the same ability, as it was perceived as demonic possession.) Namely, the power of a word is the length of the maximum subword of the form wwRwwR (where w is an arbitrary sequence of characters and wR is w written backwards). If no such subword exists, then the power of the word is 0. For example, the power of abrahellehhelleh is 12 as it contains hellehhelleh and the power of rachelhellabracadabra is 0. Note that the power of a word is always a multiple of 4.

The input contains several test cases. The first line of the input contains a positive integer Z ≤ 40, denoting the number of test cases. Then Z test cases follow, each conforming to the format described in section Input. For each test case, your program has to write an output conforming to the format described in section Output.

입력

The input is one line containing a word of length at most 3 · 105, consisting of (large or small) letters of the English alphabet.

출력

You should output one integer k being the power of the word.

제한

예제 입력 1

2
abrahellehhelleh
rachelhellabracadabra

예제 출력 1

12
0

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2010 C번

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

출처

대학교 대회

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

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