QOJ.ac

QOJ

実行時間制限: 5.0 s メモリ制限: 2048 MB 満点: 100

#14930. Server Room

統計

Audrey 是米哈游(miHoYo)的系统管理员!她的工作是管理机房,并保证她最喜欢的游戏《崩坏:星穹铁道》(Honkai: Star Rail)正常运行。

Audrey 的机房是一个矩形房间,被划分为若干行和列。房间的某些区域安装了服务器。其中一些服务器已经处于开启状态。

Audrey 急需开启更多的服务器。然而,Audrey 的机房通风较差,因此如果两个在同一行且相邻列、或在同一列且相邻行的服务器同时开启,机房就会过热,所有服务器都将关闭。

Audrey 不能关闭已经开启的服务器。请计算在不导致机房过热的前提下,Audrey 最多可以开启多少个当前处于关闭状态的服务器。此外,请计算开启该最大数量服务器的不同方案数。

输入格式

输入的第一行包含两个正整数 $r$ 和 $c$($1 \le r \times c \le 400$)。

接下来的 $r$ 行,每行包含一个长度为 $c$ 的三进制字符串 $s$。字符 0 表示该区域没有服务器,字符 1 表示该区域有一个处于关闭状态的服务器,字符 2 表示该区域有一个处于开启状态的服务器。

保证初始时没有两个相邻的服务器同时处于开启状态。

输出格式

设 $s$ 为 Audrey 最多可以开启的服务器数量,设 $w$ 为开启该数量服务器的方案数。输出两个整数,分别为 $s$ 以及 $w$ 除以 $998244353$ 的余数。

样例

输入样例 1

5 5
11011
11001
00200
10010
10000

输出样例 1

6 4

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.