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

34460번 - M(IT)+ 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB64434166.129%

문제

Busy Beaver is bored in class one day and decides to write several strings. He calls a string repetitive if it is the character M suffixed with one or more repetitions of IT. For example, the shortest repetitive strings are MIT, MITIT, MITITIT, $\dots$.

You are given a string $S$. Determine whether it can be expressed as the concatenation of one or more repetitive strings.

입력

The first line contains a single integer $T$ (1ドル \leq T \leq 1000$) --- the number of test cases.

The first line of each test case contains a single integer $|S|$ (3ドル \leq |S| \leq 2 \cdot 10^5$) --- the length of $S$.

The second line of each test case contains the string $S$ consisting of uppercase Latin characters.

The sum of $|S|$ over all test cases does not exceed 2ドル \cdot 10^5$.

출력

For each test case, output a single string "YES" or "NO" (without the quotes) denoting if the string $S$ is a concatenation of repetitive strings.

제한

예제 입력 1

6
5
MITIT
4
MITI
15
MITITMITMITITIT
6
MITITM
9
MITBEAVER
5
MIIIT

예제 출력 1

YES
NO
YES
NO
NO
NO

노트

In the first test case, the entire string MITIT is repetitive.

In the second test case, it can be shown that the string is not a concatenation of repetitive strings.

In the third test case, the string is the following concatenation of repetitive strings: MITIT + MIT + MITITIT.

출처

University > MIT > M(IT)^2 > M(IT)^2 Winter 2025 Tournament > Beginner Round 2번

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

출처

대학교 대회

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

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