2 shunfurh shunfurh 于 2017.09.10 19:29 提问

The Proper Key

Many people think that Tetris was invented by two Russian programmers. But that is not the whole truth. The idea of the game is very old -- even the Egyptians had something similar. But they did not use it as a game. Instead, it was used as a very complicated lock. The lock was made of wood and consisted of a large number of square fields, laid out in regular rows and columns. Each field was either completely filled with wood, or empty. The key for this lock was two-dimensional and it was made by joining square parts of the same size as the fields of the lock. So they had a 2D lock and 2D key that could be inserted into the lock from the top. The key was designed so that it was not possible to move it upwards. It could only fall down and it could slide sideways -- exactly like in a Tetris game. The only difference is that the key could not be rotated. Rotation in Tetris is really a Russian invention.
The entry gate into the Pyramid has such a lock. The ACM archaeologists have found several keys and one of them belongs to the lock with a very high probability. Now they need to try them out and find which one to use. Because it is too time-consuming to try all of them, it is better to begin with those keys that may be inserted deeper into the lock. Your program should be able to determine how deep a given key can be inserted into a given lock.

Input

The input consists of T test cases. The number of them (T) is given on the first line of the input. Each test case begins with a line containing two integers R and C (1 <= R, C <= 100) indicating the key size. Then exactly R rows follow, each containing C characters. Each character is either a hash mark (#) or a period (.). A hash mark represents one square field made of wood; a period is an empty field. The wooden fields are always connected, i.e. the whole key is made of one piece. Moreover, the key remains connected even if we cut off arbitrary number of rows from its top. There is always at least one non-empty field in the top-most and bottom-most rows and the left-most and right-most columns.

After the key description, there is a line containing two integers D and W (1 <= D <= 10000, 1 <= W <= 1000). The number W is the lock width, and D is its depth. The next D lines contain W characters each. The character may be either a hash mark (representing the wood) or a period (the free space).

Output

Your program should print one line of output for each test case. The line should contain the statement "The key falls to depth X.". Replace X with the maximum depth to which the key can be inserted by moving it down and sliding it to the left or right only. The depth is measured as the distance between the bottom side of the key and the top side of the lock. If it is possible to move the key through the whole lock and take it away at the bottom side, output the sentence "The key can fall through.".

Sample Input

4
2 4
#.##
###.
3 6
#....#
#....#
#..###
2 3
##.
.##
2 7
#.#.#.#
.#.#.#.
1 1
#
1 10
###....###
3 2
##
.#
.#
1 5
#.#.#

Sample Output

The key falls to depth 2.
The key falls to depth 0.
The key can fall through.
The key falls to depth 2.

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.27 22:11
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Reboot and select proper Boot device or Insert Boot Media in Selected Boot device and press a key的解决
DFGFDG
电脑启动不起来,英文提示Reboot and select proper boot device or Insert Boot Media in selected Boot
转自:http://caohongjiang.blog.51cto.com/1539096/667068 当我们启动电脑的时候,遇到启动不起来,切不管你按什么键都不管用了,都是相同的提示语,如下: Reboot and select proper boot device or Insert Boot Media in selected Boot device and press a
reboot and select proper boot device or insert boot media in selected boot device and press a key
今天开电脑就突然出现了这个问题。意思是找不到硬盘里的驱动引导。叫我们选择。  但是进行选择了也没有 。就是根本找不到硬盘。解决办法就 是要拆开机箱 把接硬盘的线从插一下就好了。接在主板的和接电源都从插一下。在重启一下就好了 。绝对有又用
华硕笔记本 reboot and select proper boot device or Insert boot media in select boot device
华硕笔记本开机出现“ reboot and select proper boot device or Insert boot media in select boot and press a key".    遇到类似问题,在去维修之前,可以参考一下下面的方法。    我的华硕笔记本型号是 FX50JX,用U盘启动安装系统时,因为通过分区工具发现,多了两个分区(格式为EFI),导致系统安
hdu 1112
模拟 注意钥匙的左右边缘不能超过锁的范围 就算是空白也不行 #include #include #include #include #include #include #include #include #include #include #define pi acos(-1.0) #define inf 1<<29 #define INF 0x3f3f3f3f #define zero 1e
Key–Value Coding (KVC 目前看到的最好的解释版本)
Cocoa derives the name of an accessor from a string name at runtime through a mechanism called key–value coding, or simply KVC. The key is a string (an NSString) that names the value to be accessed.
【hdu 1112】The Proper Key
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 487 Accepted Submission(s): 157Problem Description Many people think that Tetris was invent
重装系统遇上reboot and select proper boot device ...问题解决方案
“reboot and select proper boot device or insert boot media in selected boot device and press a key”今天装了两个系统,遇到了一系列问题,这是其中一个,英文意思大概是“ 重启,并选择正确的引导设备”。 具体的解决方法就是进入boot中,将硬盘启动设置为第一启动即可。如果还不行就再用u盘进入PE重新修复引导
hdu1112 The Proper Key ----DFS+模拟
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1112 一:原题内容 Problem Description Many people think that Tetris was invented by two Russian programmers. But that is not the whole truth. The
固态硬盘 reboot and select proper boot device
从网买一个金士顿的固态硬盘240GB,打算加装到电脑里,这样能够保证系统运行速度更快,工作效率更高。 首先准备好连接固态硬盘线,其次就是先把以前的电脑硬盘线拔掉,这样我们先做系统安装,安装成功后再把以前的硬盘插上。 通过U盘启动安装win10系统,由于固态硬盘太大,所有把这个分成2个区,用计算机管理=》磁盘管理进行分区,然后开始安装win10系统,安装完成后,重启电脑,但是在win10启动界面