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

25234번 - Tic Tac Toe Counting 다국어

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

문제

Tic Tac Toe is a simple children's game. It is played on a 3ドル \times 3$ grid. The first player places an X in any of the 9ドル$ cells. The next player places an O in any of the remaining 8 cells. The players continue to alternate placing Xs and Os in unoccupied cells until either a player gets three of their symbols in a row, or the grid is full. If either player gets three in a row, in any of the three rows, three columns or two diagonals, that player wins and the game ends.

Fred and Sam are playing a game of Tic Tac Toe. In the middle of the game, Fred wonders: "How many games from this point in the game onward are winners for X? How many for O?" Two games are different if they have different sequences of moves, even if they result in the grid looking the same at any point.

Given a list of grids, determine first if they can be reached in a game of Tic Tac Toe, and if they can, how many games from that point on result in wins for X, and how many for O.

입력

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

Each of the next $t$ lines contains a single string $s$ ($|s|=9$) which consists of only the characters '.', 'X' and/or 'O'. These are the test case grids. The first three characters represent the first row, the second three are the second row, and the last three are the last row, with '.' representing an empty cell. For example, the string XX..O.... represents this grid:

출력

For each test case, output two space-separated integers. If the grid is not reachable in a game of Tic Tac Toe, output -1 -1. If the grid is reachable, output the number of games from that point on (including that grid) that are wins for X, followed by wins for O.

제한

예제 입력 1

4
XX..O....
X...OX...
OOOX.X.X.
OOOXXX...

예제 출력 1

191 194
232 200
0 1
-1 -1

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2022 J번

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 1: Welcome Contest J번

  • 문제를 만든 사람: David Van Brackle
(追記) (追記ここまで)

출처

대학교 대회

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

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