Online Programming Server

Login

Login with facebook [?]

Facebook

Problem 1116: Tic-Tac-Toe!

Problem ID 1116
Title Tic-Tac-Toe!
pdf  
Description
Alice and Bob want to play Tic-tac-toe. This is a game where two players, X and O, take turns marking the spaces in a 3x3 grid. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game. 

You are asked to write a program to simulate the game. Name the 9 grids with number 1, 2, 3, ..., 9 as below:
1 2 3
4 5 6
7 8 9
Two players will enter the grid number just as marking the spaces during the game.
After each game, you are asked to tell which player wins or it is a draw.
Input
The first line has one character which indicates who starts first. 'A' for Alice and 'B' for Bob.
Then the second line contains at most 9 integers, as their marking for each turn.
Output
Output, 'A' when Alice wins, 'B' when Bob wins or, 'D' when it is a draw.
Sample Input
A
5 2 6 4 9 1 3
Sample Output
A
Hint
 
Last Modified 2012-12-04 12:08:30
Time Limit 1 seconds
Memory Limit 0 MB
Accepted Solutions 0
Submitted Solutions 0
Difficulty Factor 10