为什么的深搜一直不对了,先贴着以后在弄把

本文介绍了一个名为Crank的游戏算法问题,玩家需帮助角色在限定时间内到达目标建筑,通过编程解决角色如何在不同高度的建筑间移动的问题。输入包含地图布局及目标位置,输出为起始点数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


Crank

Time Limit 1000ms

Memory Limit 65536K

description

Chev Chelios had his heart stolen from him, by the boss of the most dangerous gang in the city. His heart has been replaced with an artificial chargeable one! Chelios was on mission of locating the boss of the gang to get his heart back since then without luck! Now the artificial heart’s battery lifetime is about to expire!
Fortunately, he finally located the target but he needs your help to get there before his artificial heart stops beating! Chelios decided to attack the boss building from the roof because all gates are heavily protected by gangsters. Chelios has the map of the gang block which shows the heights of all buildings within the block. The plan is that a helicopter will drop Chelios on the roof of one of the buildings on the boundary of the block during night. Then Chelios will get to the boss building by moving to adjacent buildings,
vertically or horizontally. Chelios can only move to a building which has the same or smaller height as the current building (going up severely affects his damaged heart).Given the gang building block map which shows the heights of all buildings in the block along with the boss building, write a program to help Chev Chelios determine the number of buildings on the boundary of the block he can be dropped by the helicopter at so that he would be able to reach the boss’s building without climbing!

input

The first line of input contains an integer T, the number of test cases. T test cases follow, the first line of each test case contains two integers (1 <= R,C <= 10) the height and width of the building block. The second line contains two integers (1 <= A <= R), and (1 <= B <= C), the coordinates of the boss building on the map. R lines follows; each line consists of C space separated integers representing the heights of all buildings. A height H of a building satisfies (1 <= H <= 1000).

output

For each test case, print the number of buildings on the boundary of the block Chev Chelios can be dropped by the helicopter at so that he would be able to reach the boss’s building without climbing up! Follow the output format below.

sample_input

2
3 3
2 2
1 7 3
2 6 3
3 5 4
2 2
2 1
2 7
2 6

sample_output

Case #1: 1
Case #2: 4

这题其实不需要回溯的,应为它只要求遍历就行,不强调走的路线;

转载于:https://www.cnblogs.com/one--world--one--dream/archive/2011/10/20/2219433.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值