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 ...
随机推荐
- ComputeSignature 中行支付签名报错(win7 64位系统)
在做中行加密验签的时候出现的问题.原本在XP系统下可以正常运行的,现在换了win7 64位系统就出现了这个问题,没头绪 所以发上来求各位大大支招 有什么好的解决方案.. 我的解决办法: 1.C:\Do ...
- Winform 无纸化办公-屏幕联动
最近做无纸化办公,对接硬件,用了挺多东西总结一下 技术上主要是:asp.net .winform.activeX控件.chrome插件.socket编程,websocket. 其实看着需求挺简单的,在 ...
- idea 打包java程序
创建maven项目 在pom.xml中添加: <build> <plugins> <plugin> <groupId>org.apache.maven. ...
- Swagger+ springfox +Spring mvc
简介 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...
- Cache Server
[Cache Server] Whenever a source Asset like a .psd or an .fbx file is modified, Unity detects the ch ...
- JDA 8.0.0.0小版本升级
一.升级前关服务和进行备份 二.开始升级 三. 开以下四个服务 1237 四个服务开启后需重新执行SSIS中的startingFP(去掉backupdata 05 importFP) 当以下值为0,代 ...
- dfs小练 【dfs】
1.前n个自然数的所有排列: #include <iostream> #include <cstdio> #include <cstring> using name ...
- x86汇编知识点汇总
目录: 1.进制转换 2.原码.反码.补码 3.寄存器 4.存储器的段结构 5.堆栈 6.传送类指令 7.算术运算类指令(不含乘除) 8.位操作类指令 9.标志位操作指令 10.标识符.常量与变量 1 ...
- Control(拆点+最大流)
Control http://acm.hdu.edu.cn/showproblem.php?pid=4289 Time Limit: 2000/1000 MS (Java/Others) Mem ...
- UVa 230 Borrowers(map和set)
I mean your borrowers of books - those mutilators of collections, spoilers of the symmetry of shelve ...