luogu#P5056. 【模板】插头 DP
【模板】插头 DP
Background
ural 1519.
An example problem from Chen Danqi’s article Dynamic Programming Problems Based on Connectivity State Compression.
Problem Description
Given an grid, some cells cannot be used to place lines, and all other cells must be used to place lines, forming one closed loop. How many different ways are there to place the lines?
Input Format
The first line contains two integers, representing and .
From the second line to the -th line, each line contains a string of length consisting only of * and ., where * means you cannot place lines in this cell, and . means you must place lines in this cell.
Output Format
Output one line with one integer, representing the total number of valid ways.
4 4
**..
....
....
....
2
4 4
....
....
....
....
6
Hint
Constraints
- For of the testdata, .
Translated by ChatGPT 5