HolA , Me llamo Oscar y soy de Perú, revisé tu codigo y me parece muy bueno, te cuento que yo tambien hice el puzzle, pero el mio tiene mas lineas de codigo, por eso te escribo ya que ahora tengo un problema que no lo puedo resolver aver si tu me puedes ayudar el planteamiento esta mas abajo
este en lo correo
ocuadrosl@yahoo.es
gracias.
ACM Pacific NW Region Programming Contest
10 November 2001
PROBLEM C
TRIANGLES
Write a program that, given an NxN matrix of characters, determines the number of non−trivial
single−character filled "standard" triangles in that matrix.
A "standard" triangle is an isosceles right triangle, with either:
a) the legs aligned along any two dimensions of the matrix, for example:
A BBB
AA BB
AAA B
b) the hypotenuse aligned along any one dimension of the matrix, for example:
B
A BB
AAA BBB
AAAAA BB
B
(These don’t look like right triangles, because the font isn’t perfectly square, but they are in terms of
the matrix).
No other triangles are counted.
A non−trivial triangle must contain at least 3 letters (a single letter is a trivial triangle).
Input:
The input for your program will be a sequence of matrices. Each matrix will start with a dimension
(N) that will be less than twenty, followed by N rows of N upper−case letters. The input ends with a
single zero (0) as the dimension.
Input file for this problem is C.in
Output:
For each matrix, you should print the total number of non−trivial right triangles in parentheses,
followed by the number of non−trivial triangles for each character in the matrix.
Sample I/O:
Input:
3
AAB
ABB
BBB
4
AABB
ABBB
BBBB
BBBB
0
Output:
(10) 1 A 9 B
(51) 1 A 50 B