{"problem":{"name":"Red Polyomino","description":{"content":"You are given a grid with $N$ rows and $N$ columns, where the square at the $i$\\-th row from the top and $j$\\-th column from the left is painted black if $S_{i, j}$ is `#` and white if $S_{i, j}$ is `","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc211_e"},"statements":[{"statement_type":"Markdown","content":"You are given a grid with $N$ rows and $N$ columns, where the square at the $i$\\-th row from the top and $j$\\-th column from the left is painted black if $S_{i, j}$ is `#` and white if $S_{i, j}$ is `.`.  \nYou will choose $K$ of the white squares and paint them red. How many such ways to paint the grid satisfy the following condition?\n\n*   The squares painted red will be connected. That is, you will be able to get from any red square to any red square by repeatedly moving horizontally or vertically while only visiting red squares.\n\n## Constraints\n\n*   $1 \\leq N \\leq 8$\n*   $1 \\leq K \\leq 8$\n*   Each $S_{i, j}$ is `#` or `.`.\n*   $N$ and $K$ are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$K$\n$S_{1, 1}S_{1, 2} \\dots S_{1, N}$\n$S_{2, 1}S_{2, 2} \\dots S_{2, N}$\n$\\vdots$\n$S_{N, 1}S_{N, 2} \\dots S_{N, N}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc211_e","tags":[],"sample_group":[["3\n5\n#.#\n...\n..#","5\n\nWe have five ways to satisfy the condition as shown below, where `@` stands for a red square.\n\n#.# #@# #@# #@# #@#\n@@@ .@@ @@. @@@ @@@\n@@# @@# @@# .@# @.#\n\nNote that the way shown below does not satisfy the connectivity requirement since we do not consider diagonal adjacency.\n\n#@#\n@.@\n@@#"],["2\n2\n#.\n.#","0\n\nThere is no way to satisfy the condition."],["8\n8\n........\n........\n........\n........\n........\n........\n........\n........","64678"]],"created_at":"2026-03-03 11:01:14"}}