{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. \n \u003cbr\u003e \n \u003cbr\u003eA blockhouse is a small castle that has four openings through which to shoot. The four openings are facing North, East, South, and West, respectively. There will be one machine gun shooting through each opening. \n \u003cbr\u003e \n \u003cbr\u003eHere we assume that a bullet is so powerful that it can run across any distance and destroy a blockhouse on its way. On the other hand, a wall is so strongly built that can stop the bullets. \n \u003cbr\u003e \n \u003cbr\u003eThe goal is to place as many blockhouses in a city as possible so that no two can destroy each other. A configuration of blockhouses is legal provided that no two blockhouses are on the same horizontal row or vertical column in a map unless there is at least one wall separating them. In this problem we will consider small square cities (at most 4x4) that contain walls through which bullets cannot run through. \n \u003cbr\u003e \n \u003cbr\u003eThe following image shows five pictures of the same board. The first picture is the empty board, the second and third pictures show legal configurations, and the fourth and fifth pictures show illegal configurations. For this board, the maximum number of blockhouses in a legal configuration is 5; the second picture shows one way to do it, but there are several other ways. \n \u003cbr\u003e \n \u003cbr\u003e \n \u003cimg style\u003d\"max-width:100%;\" SRC\u003d\"CDN_BASE_URL/2833d81666db37f9dec4df3db9d38734?v\u003d1534709389\"\u003e \n \u003cbr\u003e \n \u003cbr\u003eYour task is to write a program that, given a description of a map, calculates the maximum number of blockhouses that can be placed in the city in a legal configuration. \n \u003cbr\u003e \n\u003c/div\u003e\n给出一张图,图中\u0027X\u0027表示wall,\u0027.\u0027表示空地,可以放置blockhouse同一条直线上只能有一个blockhouse,除非有wall隔开,问在给出的图中最多能放置多少个blockhous"}},{"title":"Input","value":{"format":"HTML","content":"The input file contains one or more map descriptions, followed by a line containing the number 0 that signals the end of the file. Each map description begins with a line containing a positive integer n that is the size of the city; n will be at most 4. The next n lines each describe one row of the map, with a \u0027.\u0027 indicating an open space and an uppercase \u0027X\u0027 indicating a wall. There are no spaces in the input file. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one line containing the maximum number of blockhouses that can be placed in the city in a legal configuration. \n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e4\n.X..\n....\nXX..\n....\n2\nXX\n.X\n3\n.X.\nX.X\n.X.\n3\n...\n.XX\n.XX\n4\n....\n....\n....\n....\n0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e5\n1\n5\n2\n4\u003c/pre\u003e"}}]}