This page is still under construction.

Parts of this page are still being built. What you see may change.

Safe Squares

Interview

Time limit2sMemory limit512 MB

Summary
Given an 8x8 board of rooks and empty squares, count the empty squares whose row and column both contain no rook.
Level

Easy2 of 10

Topics
Array, Implementation, Brute force
Solved
No attempts yet

Problem

Penny is a young, enthusiastic pawn with significant ambitions. She hopes to improve her currently measly ranking and one day become queen of her entire chess board! Unfortunately, the current queen prefers the pawns of her kingdom do nothing but her bidding and views Penny's ambitions as a potential source of rebellion. She sends her loyal rooks onto the board to capture Penny and bring her before the royal court to face punishment.

Penny obviously does not want to be captured by the queen's rooks, but she does not know the safe spots on the board to escape to. If she goes to any square that is in the same row or same column as a rook, the rook will capture her! Given the locations of all the rooks, tell Penny how many squares there are on the chess board where she would be safe from the rooks!

Input

The input consists of 88 lines that each contain exactly 88 characters. Each line represents one row of the chessboard, and contains only R and . characters. The R characters are squares which contain a rook and the . characters represent empty squares.

Output

Print the number of squares on the chess board where Penny is safe from the rooks: where no rook is in the same row or column as the square. Note that there may be no safe squares (because the entire board is filled with rooks, or because every empty square is in the same row or column as a rook) in which case you should print 0.

Examples2

  1. Example 1

    Input
    ...R....
    ..R..R..
    R.....R.
    ....R...
    .R.....R
    ........
    .....R..
    R.......
    
    Expected output
    0
    
  2. Example 2

    Input
    .R......
    ..R.....
    ........
    ........
    ........
    ........
    ........
    ........
    
    Expected output
    36