QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#6535. 反转

統計

考虑一个大小为 $N \times M$ 的矩形网格。每个单元格都被涂成黑色或白色。

如果你触碰网格中的一个单元格 $C$,你会改变与 $C$ 同色的连通分量中所有单元格的颜色(包括 $C$ 本身)。对于连通分量,如果两个单元格共享一条边,则它们是相邻的。

你知道网格的当前状态,但你可能已经触碰过某些单元格任意次数。请计算网格可能的初始状态数量。由于答案可能非常大,请将其对 $1\,000\,000\,007$ 取模。

输入格式

第一行包含两个整数 $N$ 和 $M$,表示网格的尺寸 ($1 \le N, M \le 2000$)。

接下来的 $N$ 行,每行描述网格的一行。每行包含 $M$ 个字符,表示该行单元格的颜色。每个字符要么是 “B”(黑色),要么是 “W”(白色)。

输出格式

输出可能的初始状态数量,对 $1\,000\,000\,007$ 取模。

样例

样例输入 1

2 2
WW
WB

样例输出 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.