eolymp
bolt
Try our new interface for solving problems
Problems

Clash of the Titans

Clash of the Titans

\includegraphics{https://static.e-olymp.com/content/ba/bad05ac543afe2c3b6ce4e43ede10b2d021f8646.jpg} Sasha fond of computer games. For three days he wrote a new game for cell phone called "Clash of the Titans". Heroes toys were the tin soldiers. As a prototype for the description of actions the soldier Sasha took a chess rook. Chess rook - a figure that can move any number of squares vertically or horizontally. Ferry can not move beyond the obstacles. Problem - to calculate the maximum number of rooks that can be put on the board so that no two are not beating each other. This means that the configuration is correct, provided that no two rooks are not on the same horizontal or vertical within sight of each other. The following example shows five images. The first image is empty, second and third images show the correct configuration, and the fourth and the fifth drawing - examples of incorrect configurations. \includegraphics{https://static.e-olymp.com/content/f1/f1768d870e30f49c740f625adf1a2aa083e5b4c4.jpg} Help Sasha quickly finish the program and calculate the maximum number of rooks on a given configuration of the board. \textbf{Input } In the input file in the first line contains an integer - the size of the board, not exceeding \textbf{4}. Subsequent lines contain a description of the chessboard, with the character '.' indicates an empty cell, and the uppercase character '\textbf{X}' indicates the obstacle. In the input file, no gaps. \textbf{Output} In the output file to bring the maximum number of rooks on the correct configuration of the board.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
.X..
....
XX..
....
Output example #1
5
Source Отборочный тур Всероссийской командной олимпиады школьников 2009/2010 учебный год