Problem 3040 --Acesrc and Cube Hypernet

3040: Acesrc and Cube Hypernet

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Acesrc is fond of cube nets. If we cut some edges of a cube, the surface of the cube can be unfolded into 2-dimensional space, and the resulting flat shape is called a cube net. There are 11 essentially different cube nets, listed below. 



In this problem, we consider a generalization of the cube net, called cube hypernet. For each face of a cube, we divide it into k×kk×k small square cells. If we cut some edges of these small cells, the surface of the cube can be unfolded into 2-dimensional space, then the resulting flat shape is a cube hypernet. Clearly, cube nets are just a special type of cube hypernets where k=1k=1. The following picture illustrates a cube hypernet and explains how it is formed. 



Identifying cube nets is a relatively easy job; however, this might not be true for cube hypernets. Here comes the challenge. Given a flat shape composed of small squares, determine whether it is a cube hypernet.
The first line of the input is a single integer TT (1≤T≤30)(1≤T≤30), denoting the number of test cases. 

For each test case, the first line contains two integers h,wh,w (1≤h,w≤100)(1≤h,w≤100), denoting the height and width of the input region. Each of the remaining hh lines contains ww characters, either '#''#' or '.''.'. The character '#''#' means that the square is part of the shape, while '.''.' not. 

It is guaranteed that the input shape is nonempty and connected in four directions, and there is no hole inside the shape, not even a hole 8-connected to the outside. Also, the sum of h×wh×w over all test cases does not exceed 35000.
For each test case, output yesyes in a line if the input shape is cube hypernet, and nono otherwise.
2
6 9
...##....
...##....
########.
.########
...##....
...##....
1 6
######
yes
no

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$244 $ms] 淡意的温柔 591128 2020-06-06 08:29:31
内存最少[$2440 $KB] 淡意的温柔 591128 2020-06-06 08:29:31
第一AC 淡意的温柔 591128 2020-06-06 08:29:31
第一挑战 淡意的温柔 591128 2020-06-06 08:29:31

赛题来源/所属竞赛 2019 Multi-University Training Contest 8 N/A

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