#P10122. Cow Tic Tac Toe
Cow Tic Tac Toe
Cow Tic Tac Toe
Farmer John has 26 cows whose names begin with different letters from A–Z. To represent each cow, he uses the first letter of her name. Recently, these cows have become obsessed with tic-tac-toe. Unlike the standard game which is played by two players using only X and O, the cows fill a 3×3 board with letters A–Z. Each square is marked with the corresponding cow’s initial.
A typical board might look like this:
COW XXO ABC
The game rules are similar to standard tic-tac-toe. A single cow wins if her letter fills an entire row, column, or diagonal. In addition, the cows allow teams of two. A team wins if a row, column, or diagonal contains only the two letters of the team and both letters appear at least once in that line.
Your task is to determine how many individual cows and two‐cow teams can claim at least one winning line. Note that the same winning line may be used in the win of more than one cow or team.
inputFormat
The input consists of three lines, each line containing exactly three characters (from 'A' to 'Z'), representing the rows of the tic-tac-toe board.
outputFormat
Output two lines. The first line contains the number of individual cows that can win. The second line contains the number of two‐cow teams that can win.
sample
COW
XXO
ABC
0
2
</p>