Tic-Tac-Toe Board

0

0 votes
Medium
Problem

"Tic-Tac-Toe is a a game in which two players seek in alternate turns to complete a row, a column, or a diagonal with either three O's or three X's drawn in the spaces of a grid of nine squares." - www.google.com

INPUT FORMAT

Input begins with the uppercase letters A-I arranged in a 3 x 3 grid to represent the Tic-Tac-Toe board. The next line contains an integer T indicating the number of player moves. This is followed by T player moves. Each player move comes in the following format: Pn c, where P is the uppercase letter 'P' (as in player), n is an integer that determines the player number, and c is a character indicating the grid box in which Pn placed his token. Assume that player 1's token is the uppercase letter 'O' and player 2's token is the uppercase letter 'X'.

OUTPUT FORMAT

Display the Tic-Tac-Toe board after the moves of the players have been plotted. If there are "unused" grid boxes, mark them with an asterisk (*).

CONSTRAINTS

0 <= T <= 9
1 <= n <= 2
c is any uppercase letter from A-I

Sample Input
ABC
DEF
GHI
7
P1 A
P2 B
P1 D
P2 G
P1 E
P2 F
P1 I
Sample Output
OX*
OOX
X*O
Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?