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

24605번 - Tetris Generation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB148806053.571%

문제

The classic game Tetris involves arranging falling tetrominoes on a board. There are seven different tetrominoes, each named after a letter that resembles their shape: J, L, S, Z, I, O, and T.

In the original Tetris, the player would receive one tetromino at a time, and each tetromino would be chosen from among the seven possibilities independently and uniformly at random. This meant that any sequence of tetrominoes could appear in a game, such as numerous I tetrominoes in a row. Modern versions of Tetris remove these streaks by generating tetrominoes in groups of seven: The first seven tetrominoes in a game will be one of each of the seven different tetrominoes in a random order. The next seven tetrominoes will also be one of each of the seven different tetrominoes in a random order (possibly but not necessarily different from the ordering of the first seven). Same goes for the next seven, and so on and so forth. With this generator, it is still possible to get two of the same tetromino in a row (for example, the seventh and eighth tetrominoes in the game can be the same as each other), but it is not possible to get three of the same type in a row.

Given a sequence of tetrominoes, determine whether it is possible for a modern Tetris generator to produce that sequence at some point in a game.

입력

The first line of input contains an integer $t$ (1ドル \le t \le 10^5$), which is the number of test cases.

Each of the next $t$ lines contains a single string $s$ (1ドル \le |s| \le 1{,}000, s \in \{\texttt{J}, \texttt{L}, \texttt{S}, \texttt{Z}, \texttt{I}, \texttt{O}, \texttt{T}\}^*$). This string represents a sequence of tetrominoes, and is a single test case.

The sum of the lengths of all input test cases will not exceed 10ドル^5$.

출력

For each test case, output a single line with a single integer, which is 1 if the sequence can be generated by a modern Tetris generator, and 0 otherwise.

제한

예제 입력 1

2
JJTO
JJTT

예제 출력 1

1
0

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2021 ICPC Pacific Northwest Region > Division 2 Q번

ICPC > Regionals > North America > South Central USA Regional > 2021 South Central USA Regional Contest > Division 1 H번

ICPC > Regionals > North America > South Central USA Regional > 2021 South Central USA Regional Contest > Division 2 I번

ICPC > Regionals > North America > Mid-Central Regional > Mid-Central USA Programming Contest 2021 G번

ICPC > Regionals > North America > Northeast North America Regional > 2021 Northeast North America Regional Contest C번

ICPC > Regionals > North America > Southeast USA Regional > 2021 Southeast USA Regional Programming Contest > Division 1 H번

ICPC > Regionals > North America > Southeast USA Regional > 2021 Southeast USA Regional Programming Contest > Division 2 I번

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

출처

대학교 대회

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

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