Mock CCC '15 J4 - Vox in Box

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 0.6s
Memory limit: 64M

Authors:
Problem type
2015 Mock CCC by Alex and Timothy

Michiru has an interesting Volvox colony which she keeps in a square open-air box (to allow them to photosynthesize). The base of the box is a square with a side length of N units (1 \le N \le 1\,000). One day, she took a picture of it and printed out an ASCII image of the colony. The image is made of the characters ., O, (, ), /, and \. Since Michiru is an inquisitive girl, she would like to know how many lines of symmetry there are in her Volvox colony.

A line of symmetry can be one of 4 types of lines — either a horizontal line, a vertical line, a diagonal line running top-left to bottom-right, or a diagonal line running top-right to bottom-left. The horizontal and vertical lines must be parallel to the sides of the box, while the diagonal lines must be at 45^{\circ} angles relative to the sides. Furthermore, a line of symmetry should divide the ASCII image into two halves of equal area which are symmetrical to each other with respect to that line.

For individual characters on the ASCII image, Michiru has observed that:

  • The characters . and O are symmetrical to themselves in all 4 directions.
  • The characters ( and ) are symmetrical to themselves horizontally, symmetrical to each other vertically, and are asymmetrical diagonally.
  • The characters / and \ are symmetrical to themselves diagonally, and symmetrical to each other both vertically and horizontally.

Please help Michiru count the number of lines of symmetry.

Input Specification

Line 1 of input will contain a single integer N, the side length of the box.

The next N lines will each contain N characters, depicting an ASCII image of the Volvox colony.

Output Specification

The output should be one integer, the number of lines of symmetry.

Sample Input 1

5
.....
.....
.(O).
.....
.....

Sample Output 1

2

Explanation for Sample 1

The Volvox is symmetrical horizontally and vertically, but not diagonally.

Sample Input 2

5
/...\
..O..
.OOO.
..O..
\.../

Sample Output 2

4

Sample Input 3

6
..\/..
\(OO)/
(OOOO)
(OOOO)
/(OO)\
../\..

Sample Output 3

2

Comments


  • 0
    omaewamoushindeiru  commented on May 23, 2015, 5:17 p.m.

    "characters ( and ) are symmetrical to themselves horizontally"

    isn't it supposed to be 'to each other'


    • 5
      lolzballs  commented on May 24, 2015, 10:16 p.m.

      I believe that it is correct, as a horizontal line is this ("-----------------") way. "(" reflected on that line is itself hence it is symmetrical to itself horizontally. The same applies to ")".


      • 3
        omaewamoushindeiru  commented on May 25, 2015, 12:50 a.m.

        Thanks! I love you balls!


        • 15
          bobhob314  commented on May 25, 2015, 10:30 p.m.

          *your


      • 0
        bobhob314  commented on May 24, 2015, 10:21 p.m.

        Yeah we figured this out yesterday too. Thanks lolzballs!


    • 0
      bobhob314  commented on May 23, 2015, 8:24 p.m.

      I think you're right...