Fruit Boats
View as PDFIn the land of TSSOJ, there are certain fruits that are banned for being too fruity. is a fruit smuggler who smuggles illegal fruits into TSSOJ by plane. One day, one of his fruit shipments containing apples, bananas and coconuts is intercepted and his plane is destroyed while flying over a square shaped lake. All the fruit falls out, but because of the way the fruit is stored, they land neatly next to each other in a grid formation. sends two boats to recover as much of the fruit as he can. Unfortunately, most of the island is already under surveillance by the TSSOJ government. decides that the best way to recover as much fruit as possible is the send the boats in an X formation across the river, collecting any fruit they encounter.
The path of the boats is visualized in the following image:

Your task is to determine how much of each fruit will be collected.
Input Specification
The first line of input,
represents the number of fruit from one end of the lake to directly across on the other. In other words, the lake can be split into a grid of size
x
with a fruit in each square. It is guaranteed that
will be odd.
The next lines will contain
space separated letters representing the type of fruit that is in each square.
A for apple, B for banana and C for coconut.
Output Specification
Output 3 integers, each on a new line representing the number of each type of fruit collected, in the order of apples, bananas, coconuts.
Subtask 1
For 5/7 of the points, .
Sample Input
5
A A B A C
B A C C A
C C B A B
C A C B C
A B A A A
Sample Output
5
2
2
Explanation for Sample Input
The path of the fruit boats is visualized in the following image:

In total, the boats will encounter 5 apples, 2 bananas, and 2 coconuts.
Comments