CF578F.Mirror Box
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a box full of mirrors. Box consists of grid of size n × m. Each cell of the grid contains a mirror put in the shape of '\' or ' / ' (45 degree to the horizontal or vertical line). But mirrors in some cells have been destroyed. You want to put new mirrors into these grids so that the following two conditions are satisfied:
- If you put a light ray horizontally/vertically into the middle of any unit segment that is side of some border cell, the light will go out from the neighboring unit segment to the segment you put the ray in.
- each unit segment of the grid of the mirror box can be penetrated by at least one light ray horizontally/vertically put into the box according to the rules of the previous paragraph

After you tried putting some mirrors, you find out that there are many ways of doing so. How many possible ways are there? The answer might be large, so please find the result modulo prime number MOD.
你有一个装满镜子的盒子。该盒子由一个 n×m 的网格构成。网格的每个单元格中放置了一面镜子,其形状为 '\\' 或 '/'(即与水平线或垂直线成 45 度角)。但其中某些单元格中的镜子已被损坏。你需要在这些损坏的单元格中重新安装镜子,使得以下两个条件均被满足:
- 若将一束光线水平或垂直地射入任意一个边界单元格的某条边的中点(即该边所对应的单位线段的中点),则该光线最终将从与入射线段相邻的另一条单位线段射出;
- 网格中镜子盒的每一条单位线段,都至少能被某一条按上述规则水平或垂直射入盒子的光线所穿透。

在你尝试安装若干镜子后,发现满足条件的安装方式有很多种。那么,总共有多少种可能的安装方式?答案可能很大,请对给定的质数模数 MOD 取模后输出。
输入格式
The first line contains three integers n, m, MOD (1 ≤ n, m ≤ 100, 3 ≤ MOD ≤ 109 + 7, MOD is prime), m, n indicates the dimensions of a box and MOD is the number to module the answer.
The following n lines each contains a string of length m. Each string contains only ' / ', '\', '*', where '*' denotes that the mirror in that grid has been destroyed.
It is guaranteed that the number of '*' is no more than 200.
第一行包含三个整数 n、m、MOD(1≤n,m≤100,3≤MOD≤109+7,且 MOD 为质数),其中 m、n 表示一个盒子的尺寸,MOD 表示对答案取模的数。
接下来的 n 行,每行包含一个长度为 m 的字符串。每个字符串仅由字符 '/'、'\' 和 '*' 组成,其中 '*' 表示该网格位置的镜子已被破坏。
保证 '*' 的个数不超过 200。
输出格式
Output the answer modulo MOD.
对 MOD 取模输出答案。
输入输出样例
输入#1
2 2 1000000007 */ /*
输出#1
1
输入#2
2 2 1000000007 ** \\
输出#2
1
输入#3
2 2 3 ** **
输出#3
2
说明/提示
The only way for sample 1 is shown on the left picture from the statement.
The only way for sample 2 is shown on the right picture from the statement.
For the third sample, there are 5 possibilities that are listed below:










The answer is then module by 3 so the output should be 2.
样例 1 的唯一方案如题目描述中的左图所示。
样例 2 的唯一方案如题目描述中的右图所示。
对于第三个样例,共有以下 5 种可能:










答案对 3 取模,因此输出应为 2。
输入解题思路,AI测评打分。不知道怎么写?