logo AlgoBeat OnlineJudge
登录 注册

#217697. [PacNW 2025] Server Room

内存限制:2048 MiB 时间限制:5000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Audrey is system administrator for miHoYo! It is her job to manage the server room and keep her favorite video game, Honkai: Star Rail, up and running.

Audrey manages a rectangular server room divided into rows and columns. Some cells contain servers, and some of those servers are already on.

The room has poor ventilation. If two orthogonally adjacent servers are both on, the room overheats and every server shuts down. Audrey cannot turn off a server that is already on.

Find the maximum number of currently off servers Audrey can turn on without causing overheating, and count the number of distinct ways to turn on that many servers.

输入格式

The first line contains two positive integers and with .

Each of the next lines contains a string of length over 0, 1, and 2. A 0 denotes a cell without a server, a 1 an off server, and a 2 an on server. No two initially on servers are adjacent.

输出格式

Let be the maximum number of additional servers that can be turned on, and let be the number of ways to turn on exactly servers. Output and .

样例

样例输入 1

5 5
11011
11001
00200
10010
10000

样例输出 1

6 4