{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"题目","value":{"format":"HTML","content":"\u003cp\u003e有一个网格,由 $$$2$$$ 行和 $$$n$$$ 列组成。网格的每个单元格要么是自由的,要么是被阻塞的。\u003c/p\u003e\u003cp\u003e一个自由单元格 $$$y$$$ 可以从另一个自由单元格 $$$x$$$ 到达,如果满足以下任一条件:\u003c/p\u003e\u003cul\u003e \u003cli\u003e $$$x$$$ 和 $$$y$$$ 共享一个边;\u003c/li\u003e\u003cli\u003e 存在一个自由单元格 $$$z$$$,使得 $$$z$$$ 可以从 $$$x$$$ 到达,并且 $$$y$$$ 可以从 $$$z$$$ 到达。\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e一个连通区域是网格中一组自由单元格,使得其中的所有单元格彼此可达,但将任何其他自由单元格添加到该集合会违反此规则。\u003c/p\u003e\u003cp\u003e例如,考虑以下布局,其中白色单元格是自由的,深灰色单元格是被阻塞的:\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/35b42e4e3c64eee3071df3d7b48861e8?v\u003d1722357823\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e \u003cp\u003e该网格中有 $$$3$$$ 个区域,分别用红色、绿色和蓝色表示:\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/b2528153b76de41b1afcd49c1578a191?v\u003d1722357823\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e \u003cp\u003e给定的网格最多包含 $$$1$$$ 个连通区域。你的任务是计算满足以下条件的自由单元格的数量:\u003c/p\u003e\u003cul\u003e \u003cli\u003e 如果该单元格被阻塞,连通区域的数量恰好变为 $$$3$$$。\u003c/li\u003e\u003c/ul\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数 $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u0026nbsp;— 测试用例的数量。\u003c/p\u003e\u003cp\u003e每个测试用例的第一行包含一个整数 $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$)\u0026nbsp;— 列的数量。\u003c/p\u003e\u003cp\u003e接下来的两行中的第 $$$i$$$ 行包含网格第 $$$i$$$ 行的描述\u0026nbsp;— 字符串 $$$s_i$$$,由 $$$n$$$ 个字符组成。每个字符要么是 \u003cspan class\u003d\"tex-font-style-tt\"\u003e.\u003c/span\u003e(表示自由单元格),要么是 \u003cspan class\u003d\"tex-font-style-tt\"\u003ex\u003c/span\u003e(表示被阻塞的单元格)。\u003c/p\u003e\u003cp\u003e输入的附加约束:\u003c/p\u003e\u003cul\u003e \u003cli\u003e 给定的网格最多包含 $$$1$$$ 个连通区域;\u003c/li\u003e\u003cli\u003e 所有测试用例中 $$$n$$$ 的总和不超过 $$$2 \\cdot 10^5$$$。\u003c/li\u003e\u003c/ul\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,打印一个整数\u0026nbsp;— 如果该单元格被阻塞,连通区域的数量变为 $$$3$$$ 的单元格数量。\u003c/p\u003e"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n8\n.......x\n.x.xx...\n2\n..\n..\n3\nxxx\nxxx\n9\n..x.x.x.x\nx.......x\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n0\n0\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在第一个测试用例中,如果单元格 $$$(1, 3)$$$ 被阻塞,连通区域的数量变为 $$$3$$$(如题目中的图片所示)。\u003c/p\u003e"}}]}