Logo
(追記) (追記ここまで)

34791번 - Server Room 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 2048 MB84450.000%

문제

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's server room is a rectangular room that is broken up into some rows and columns. Some areas in the room have servers installed. Some of the servers are already turned on.

Audrey urgently needs to turn on more servers. However, Audrey's server room has bad ventilation, so if two servers that are either in the same row and adjacent columns or in the same column and adjacent rows are both on, then the room will overheat and all the servers will shut down.

Audrey cannot turn off servers that are already on. Compute the maximum number of servers Audrey can turn on from the ones that are currently off without causing the room to overheat. Furthermore, compute the number of distinct ways to turn on that many servers.

입력

The first line of input contains two positive integers, $r$ and $c$ (1ドル \le r \times c \le 400$).

The next $r$ lines of input each contain a ternary string $s$ of length $c$. A character of 0 represents a section with no server, a character of 1 represents a section with a server that is off, and a character of 2 represents a section with a server that is on.

It is guaranteed that no two servers which are adjacent are both on.

출력

Let $s$ be the maximum number of servers that Audrey can turn on, and let $w$ be the number of ways to turn on that many servers. Output two integers, $s,ドル and the remainder when $w$ is divided by 998244353ドル$.

제한

예제 입력 1

5 5
11011
11001
00200
10010
10000

예제 출력 1

6 4

노트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2025 ICPC Pacific Northwest Regional > Division 1 J번

  • 문제를 만든 사람: Nick Wu
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /