CF1900A Cover in Water

题目描述

Filip 有一行单元格,一些是障碍物,另一些是空的。他希望把所有空的单元格都灌上水,为此可以进行如下两种操作: - $ 1 $ — 在一个空的单元格中灌上水。 - $ 2 $ — 把一个有水单元格中的水移除并改放置到另一个空的单元格中。 如果在某时刻单元格 $ i $ ( $ 2 \le i \le n-1 $ ) 是空的,但 $ i-1 $ 和 $ i+1 $ 都有水, 则它会被立刻灌上水。 找出把所有空的单元格都灌上水所需要的最少的操作1次数。 注意你不用最小化操作2次数;障碍物格子无法灌水。

输入格式

第一行 $ t $ ( $ 1 \le t \le 100 $ ),为数据组数。 每组数据第一行 $ n $ ( $ 1 \le n \le 100 $ ) ,为单元格个数。第二行一个$ n $长度字符串 $ s $,其中第$ i $ 个字符为'.' 表示格子 $ i $是空的, '\#' 表示格子 $ i $ 是障碍物。

输出格式

对每组数据,在一行中输出最小的操作1次数。

说明/提示

Test Case 1 In the first test case, Filip can put water in cells $ 1 $ and $ 3 $ . As cell $ 2 $ is between $ 2 $ cells with water, it gets filled with water too. Test Case 2 In the second case, he can put water sources in cells $ 3 $ and $ 5 $ . That results in cell $ 4 $ getting filled with water. Then he will remove water from cell $ 5 $ and place it into cell $ 6 $ . As cell $ 5 $ 's neighbors, cell $ 4 $ and cell $ 6 $ , have water in them, cell $ 5 $ also gets filled with water. You can see the illustration of this case below. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1900A/c631b21487472137a395b972e5cbe2608bd5e3f1.png) Operations in the second test case. White cells are empty, grey ones are blocked, and blue ones are water.Test Case 3 In the third case, he can put water in all the empty cells. That requires $ 5 $ actions of type $ 1 $ . Test Case 4 In the fourth case, there are no empty cells. Therefore, he does not have to put any water in them. Test Case 5 In the fifth test case, there exists a sequence of actions that requires only $ 2 $ type $ 1 $ actions.