QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100

#5576. ICPC 广告

Estadísticas

你正在制作一面旗帜来宣传 ICPC!这面旗帜是一个网格,其中已经填入了一些“C”、“I”和“P”字母。如果旗帜中存在至少一个 $2 \times 2$ 的子网格看起来完全如下所示,则称该旗帜为“宣传 ICPC 的旗帜”:

IC PC

旗帜不能旋转或翻转。网格中的每个方格都必须填入“C”、“I”或“P”。请计算有多少种填充旗帜上未填位置的方法,使得该旗帜成为“宣传 ICPC 的旗帜”。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($2 \le n, m \le 8$),其中 $n$ 是网格的行数,$m$ 是网格的列数。

接下来的 $n$ 行,每行包含一个长度为 $m$ 的字符串。字符串中的每个字符要么是“C”、“I”、“P”,要么是“?”。“?”表示该位置尚未填入字母。

这 $n$ 行构成了代表旗帜的网格。

输出格式

输出一个整数,表示使得旗帜成为“宣传 ICPC 的旗帜”的填充方法数,结果对 $998\,244\,353$ 取模。

样例

样例输入 1

3 3
???
?I?
???

样例输出 1

243

样例输入 2

2 2
IC
PC

样例输出 2

1

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.