博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Saving Princess claire_(hdu 4308 bfs模板题)
阅读量:6933 次
发布时间:2019-06-27

本文共 3096 字,大约阅读时间需要 10 分钟。

 

                   Saving Princess claire_

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2305    Accepted Submission(s): 822

Problem Description
Princess claire_ was jailed in a maze by Grand Demon Monster(GDM) teoy.
Out of anger, little Prince ykwd decides to break into the maze to rescue his lovely Princess.
The maze can be described as a matrix of r rows and c columns, with grids, such as 'Y', 'C', '*', '#' and 'P', in it. Every grid is connected with its up, down, left and right grids.
There is only one 'Y' which means the initial position when Prince ykwd breaks into the maze.
There is only one 'C' which means the position where Princess claire_ is jailed.
There may be many '*'s in the maze, representing the corresponding grid can be passed through with a cost of certain amount of money, as GDM teoy has set a toll station.
The grid represented by '#' means that you can not pass it.
It is said that as GDM teoy likes to pee and shit everywhere, this grid is unfortunately damaged by his ugly behavior.
'P' means it is a transmission port and there may be some in the maze. These ports( if exist) are connected with each other and Prince ykwd can jump from one of them to another.
They say that there used to be some toll stations, but they exploded(surely they didn't exist any more) because of GDM teoy's savage act(pee and shit!), thus some wormholes turned into existence and you know the following things. Remember, Prince ykwd has his mysterious power that he can choose his way among the wormholes, even he can choose to ignore the wormholes.
Although Prince ykwd deeply loves Princess claire_, he is so mean that he doesn't want to spend too much of his money in the maze. Then he turns up to you, the Great Worker who loves moving bricks, for help and he hopes you can calculate the minimum money he needs to take his princess back.
 

 

Input
Multiple cases.(No more than fifty.)
The 1st line contains 3 integers, r, c and cost. 'r', 'c' and 'cost' is as described above.(0 < r * c <= 5000 and money is in the range of (0, 10000] )
Then an r * c character matrix with 'P' no more than 10% of the number of all grids and we promise there will be no toll stations where the prince and princess exist.
 

 

Output
One line with an integer, representing the minimum cost. If Prince ykwd cannot rescue his princess whatever he does, then output "Damn teoy!".(See the sample for details.)
 

 

Sample Input
1 3 3
Y*C
1 3 2
Y#C
1 5 2
YP#PC
 
Sample Output
3
Damn teoy!
0
 题目唯一需要注意的是,P是传送带,可进入所有传送带。
#include 
#include
#include
#include
using namespace std;int n,m,V;char map[1001][1001];int v[1001][1001];struct node{ int x,y,ans;}q[100001];int jx[]={
1,-1,0,0};int jy[]={
0,0,1,-1};void bfs(int xx,int yy){ int e=0; int s=0; memset(v,0,sizeof(v)); struct node t,f; t.x=xx; t.y=yy; t.ans=0; v[t.x][t.y]=1; q[e++]=t; while(s
=0&&f.x
=0&&f.y
View Code

 

 

转载地址:http://sjmjl.baihongyu.com/

你可能感兴趣的文章
linux存储技术与应用:Multipath多路径
查看>>
hadoop 2.2.X 配置参数说明:hdfs-site.xml
查看>>
Raspberry Pi 安装os
查看>>
ansible+corosync+pacemaker实现对web服务高可用
查看>>
zabbix配置grafana图形显示插件
查看>>
HDU1274 士兵队列训练问题
查看>>
linux每天积累一点点(学习笔记积累)
查看>>
我的友情链接
查看>>
Centos下构建Nagios监控平台提示“无权限访问nagios”?
查看>>
GTID复制模式手动跳过复制错误
查看>>
CRT连接Vmware CentOS
查看>>
使用Javascript来编写贪食蛇(零基础)
查看>>
Linux下重导进程输出
查看>>
C# Excel导入数据
查看>>
js友好提示是否继续,post提交
查看>>
[20170825]11G备库启用DRCP连接3.txt
查看>>
mysql语句修改zencart产品原价为特价的倍数
查看>>
Python-pycurl模块的安装
查看>>
获取和设置用户id以及组id
查看>>
lsjORM ----让开发变得更加快捷(二)
查看>>