HDU1181 变形课(DFS) 2016-07-24 13:31 73人阅读 评论(0) 收藏
变形课
Problem Description
Harry已经将他所会的所有咒语都列成了一个表,他想让你帮忙计算一下他是否能完成老师的作业,将一个B(ball)变成一个M(Mouse),你知道,如果他自己不能完成的话,他就只好向Hermione请教,并且被迫听一大堆好好学习的道理.
Input
Output
Sample Input
so
soon
river
goes
them
got
moon
begin
big
0
Sample Output
Yes.
Hint
Harry 可以念这个咒语:"big-got-them".
————————————————————————————————————————————
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std; using namespace std;
const int maxn = 100000; char st[maxn], et[maxn];
int vis[maxn], t;
bool ok; void DFS(int x){
if (et[x] == 'm'){
ok = true; return;
}
for (int i = 0; i<t; ++i){
if (vis[i] || st[i] != et[x])
continue;
vis[i] = 1;
DFS(i);
vis[i] = 0;
if (ok)return;
}
} int main() {
char s[1000];
int k;
while (~scanf("%s",s))
{
t = 0;
while (s[0] != '0')
{
k = strlen(s);
st[t] = s[0];
et[t++] = s[k- 1];
scanf("%s", s);
}
memset(vis, 0, sizeof(vis));
ok = false;
for (int i = 0; i<t; ++i)
{
if (st[i] != 'b')
continue;
vis[i] = 1;
DFS(i);
}
if (ok)
printf("Yes.\n");
else printf("No.\n");
}
return 0;
}
HDU1181 变形课(DFS) 2016-07-24 13:31 73人阅读 评论(0) 收藏的更多相关文章
- 积分图像的应用(一):局部标准差 分类: 图像处理 Matlab 2015-06-06 13:31 137人阅读 评论(0) 收藏
局部标准差在图像处理邻域具有广泛的应用,但是直接计算非常耗时,本文利用积分图像对局部标准差的计算进行加速. 局部标准差: 标准差定义如下(采用统计学中的定义,分母为): 其中. 为了计算图像的局部标准 ...
- HDU1426 Sudoku Killer(DFS暴力) 2016-07-24 14:56 65人阅读 评论(0) 收藏
Sudoku Killer Problem Description 自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视. 据说,在2008北京奥运会上,会 ...
- HDU1312 Red and Black(DFS) 2016-07-24 13:49 64人阅读 评论(0) 收藏
Red and Black Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- HDU1045 Fire Net(DFS枚举||二分图匹配) 2016-07-24 13:23 99人阅读 评论(0) 收藏
Fire Net Problem Description Suppose that we have a square city with straight streets. A map of a ci ...
- HDU2212 DFS 2016-07-24 13:52 56人阅读 评论(0) 收藏
DFS Problem Description A DFS(digital factorial sum) number is found by summing the factorial of eve ...
- POJ1087 A Plug for UNIX 2017-02-12 13:38 40人阅读 评论(0) 收藏
A Plug for UNIX Description You are in charge of setting up the press room for the inaugural meeting ...
- 百度地图-省市县联动加载地图 分类: Demo JavaScript 2015-04-26 13:08 530人阅读 评论(0) 收藏
在平常项目中,我们会遇到这样的业务场景: 客户希望把自己的门店绘制在百度地图上,通过省.市.区的选择,然后加载不同区域下的店铺位置. 先看看效果图吧: 实现思路: 第一步:整理行政区域表: 要实现通过 ...
- 棋盘问题 分类: 搜索 POJ 2015-08-09 13:02 4人阅读 评论(0) 收藏
棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28474 Accepted: 14084 Description 在一 ...
- Power Network 分类: POJ 2015-07-29 13:55 3人阅读 评论(0) 收藏
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 24867 Accepted: 12958 Descr ...
随机推荐
- iKcamp|基于Koa2搭建Node.js实战(含视频)☞ 代码分层
视频地址:https://www.cctalk.com/v/15114923889408 文章 在前面几节中,我们已经实现了项目中的几个常见操作:启动服务器.路由中间件.Get 和 Post 形式的请 ...
- Centos 安装Mongo DB
NOSQL在很短的时间里使用人数据高涨,这不仅是它提出的一种新存储思想,更是因为它在对大数据做操作的效率,明显高于关系数据库 工具/原料 接入Internet的一台Centos计算机 下载安装文件 ...
- IE低版本浏览器兼容问题
head标签中填写如下代码 <meta name="renderer" content="webkit"/> <meta name=" ...
- zoj1109-Language of FatMouse 【字典树】
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=109 Language of FatMouse Time Limit: 10 S ...
- Python bool() 函数
Python bool() 函数 Python 内置函数 描述 bool() 函数用于将给定参数转换为布尔类型,如果没有参数,返回 False. bool 是 int 的子类. 语法 以下是 boo ...
- thinkphp下多语言
这里指定2种语言 ,zh-cn 和 zh-tw 1.在配置文件中写入 'LANG_SWITCH_ON' => true, // 开启语言包功能 'LANG_AUTO_DETECT' => ...
- js Function 函数
函数 var abs = function (x) { if (x >= 0) { return x; } else { return -x; } }; 函数体内部的语句在执行时,一旦执行到re ...
- centos6.6 下 安装 php7 按 nginx方式
1.安装必要的依赖库 > yum -y install gd zlib libjpeg libjpeg-devel libpng libpng-devel freetype freetype-d ...
- Combobox实现多项选择 Silverlight下“Combobox”怎样实现多项选择?
把 combobox里面的项换成checkedbox 示例: combobox cbb=new combobox(); ) { CheckBox cb = new CheckBox(); cb.Com ...
- bootstrap下modal模态框中webuploader控件按钮异常(无法点击)问题解决办法【转】
http://bbs.csdn.net/topics/391917552 具体如下: $(function () { var _$modal = $('#MyModal'); ...