#abc377b. B - Avoid Rook Attack

B - Avoid Rook Attack

Score : 200200 points

问题陈述

有一个由 6464 个方格组成的棋盘,分为 88 行和 88 列。用 (i,j)(i,j) 表示从顶部数第 ii(1i8)(1\leq i\leq8) 和从左边数第 jj(1j8)(1\leq j\leq8) 的方格。

每个方格要么为空,要么上面放置了一个棋子。方格的状态由一个长度为 88 的字符串序列 (S1,S2,S3,,S8)(S_1,S_2,S_3,\ldots,S_8) 表示。如果 SiS_i 中的第 jj 个字符是 .,则方格 (i,j)(i,j) (1i8,1j8)(1\leq i\leq8,1\leq j\leq8) 为空;如果是 #,则表示有棋子。

你想要在一个 空方格 上放置你的棋子,使得它 不能被任何现有的棋子捕获

放置在方格 (i,j)(i,j) 上的棋子可以捕获满足以下任一条件的棋子:

  • 放置在第 ii 行的方格上
  • 放置在第 jj 列的方格上

例如,放置在方格 (4,4)(4,4) 上的棋子可以捕获下图中蓝色显示的方格上的棋子:

你可以在多少个方格上放置你的棋子?

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There is a grid of 6464 squares with 88 rows and 88 columns. Let (i,j)(i,j) denote the square at the ii-th row from the top (1i8)(1\leq i\leq8) and jj-th column from the left (1j8)(1\leq j\leq8).

Each square is either empty or has a piece placed on it. The state of the squares is represented by a sequence (S1,S2,S3,,S8)(S_1,S_2,S_3,\ldots,S_8) of 88 strings of length 88. Square (i,j)(i,j) (1i8,1j8)(1\leq i\leq8,1\leq j\leq8) is empty if the jj-th character of SiS_i is ., and has a piece if it is #.

You want to place your piece on an empty square in such a way that it cannot be captured by any of the existing pieces.

A piece placed on square (i,j)(i,j) can capture pieces that satisfy either of the following conditions:

  • Placed on a square in row ii
  • Placed on a square in column jj

For example, a piece placed on square (4,4)(4,4) can capture pieces placed on the squares shown in blue in the following figure:

How many squares can you place your piece on?

Constraints

  • Each SiS_i is a string of length 88 consisting of . and # (1i8)(1\leq i\leq 8).

Input

The input is given from Standard Input in the following format:

S1S_1

S2S_2

S3S_3

S4S_4

S5S_5

S6S_6

S7S_7

S8S_8

Output

Print the number of empty squares where you can place your piece without it being captured by any existing pieces.

Sample Input 1

...#....
#.......
.......#
....#...
.#......
........
........
..#.....

Sample Output 1

4

The existing pieces can capture pieces placed on the squares shown in blue in the following figure:

Therefore, you can place your piece without it being captured on 44 squares: square (6,6)(6,6), square (6,7)(6,7), square (7,6)(7,6), and square (7,7)(7,7).

Sample Input 2

........
........
........
........
........
........
........
........

Sample Output 2

64

There may be no pieces on the grid.

Sample Input 3

.#......
..#..#..
....#...
........
..#....#
........
...#....
....#...

Sample Output 3

4
}