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

34903번 - MIT and TIM 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB131312100.000%

문제

Busy Beaver is studying Archaeology and Materials at MIT! He has been studying ancient inscriptions made only of the letters M, I, and T and notices the following rule: any time the substring MIT appears, it may be rearranged into TIM, and any time TIM appears, it may be rearranged back into MIT.

Now Busy Beaver wants to form as many occurrences as possible of his favorite pattern, MITIT, in the string. Help him determine the maximum number of contiguous substrings equal to MITIT that can appear after performing any number of operations (possibly zero).

입력

The first line contains an integer $T$ $(1 \le T \le 10^5)$ --- the number of test cases.

The only line of each test case contains a string of length at most 10ドル^5$ consisting of the characters M, I, and T.

The total length of all strings does not exceed 10ドル^5$.

출력

For each test case, output a single integer --- the maximum number of substrings MITIT that can appear after performing any number of operations.

제한

예제 입력 1

6
TITIMMIT
TITITIMITIMTMTMTMMITMI
MIMTITMTIMTITMTITITMTI
ITMTTMITMITMTMTITITMIM
MMITMITTTIMTITITTTITIT
MITITIMIMIMITITITITIMIMIMIMIMIMITITITITTIIMITMTIMTIITMITMTIMTITIITITMTIMI

예제 출력 1

1
2
0
0
0
5

노트

In the first test case, we can do the following operations: TITIMMIT $\to$ TIMITMIT and TIMITMIT $\to$ MITITMIT. We can prove that it is impossible to construct two copies of MITIT inside this string.

출처

University > MIT > M(IT)^2 > M(IT)^2 Winter 2025-26 Tournament > Advanced Individual Round 1번

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

출처

대학교 대회

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

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