Problem 3805 --Yinyang

3805: Yinyang

"
Time Limit $1$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
You have a grid of n rows and m columns, each cell should be painted either black or white.
The cell in the ith row and jth column is denoted as (i,j).
Two cells are directly connected if and only if they have a common edge and have the same color.
Two cells are connected if and only if they are directly connected or there exist a cell connected to both cells.
A painting plan is good if and only if it satisfy three conditions:
1. All white cells are connected 
2. All black cells are connected
3. ∀1≤i<n,1≤j<m, cell(i,j),(i,j+1),(i+1,j)and(i+1,j+1) can't have the same color.
Some of the cells have been painted, you should paint the rest .
output the number of good painting plans module 998244353.
The first line of input contains an integer T(T≤10), denoting the number of test cases.
Each test case contains n+1 lines.
The first line contains two integer n,m(3≤n≤100,3≤m≤100,n∗m<=100), denoting the size of the grid. 
The next n lines describe the painted cells, each line contains m integer. 
The jth number in ith row describe cell(i,j),the number is 0,1 or −1.
0 means the cell is painted white,1 means the cell is painted black, −1 means the cell is not painted.
Output the number of good painting plans module 998244353.
3
3 3
1 0 0
1 1 0
-1 -1 0
3 4
1 -1 -1 0
-1 -1 -1 -1
0 -1 -1 1
10 10
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
2
0
139719073

推荐代码 查看3805 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛