中文题

深搜

许久没写鸟,卡在输入问题上...

 #include <iostream>
#include <string>
using namespace std;
bool flg;
int n;
char str[][];
bool used[];
void dfs(int p)
{
int i;
if (p >=n || flg) return;
if (str[p][] == 'm')
{
flg = true;
return;
}
for (i=; i<n; i++)
if (!used[i] && str[i][] == str[p][])
{
used[i] = true;
dfs(i);
used[i] = false; }
}
int main()
{ int i;
string tmp;//="12345";
//cout<<tmp.back()<<endl;
while (cin>>tmp && tmp[] != '')
{
i=;
flg = false;
memset(used, false, sizeof(used));
str[i][] = tmp[];
str[i++][] = tmp[tmp.length()-];
while (cin>>tmp && tmp[] != '')
{
str[i][] = tmp[];
str[i++][] = tmp[tmp.length()-];
}
n = i;
for (i=; i<n; i++)
if (!flg && str[i][] == 'b')
{
used[i] = true;
dfs(i);
used[i] = false;
}
if (flg)
cout<<"Yes."<<endl;
else cout<<"No."<<endl;
}
}

hdu 1181 深搜的更多相关文章

  1. HDU 3720 深搜 枚举

    DES:从23个队员中选出4—4—2—1共4种11人来组成比赛队伍.给出每个人对每个职位的能力值.给出m组人在一起时会产生的附加效果.问你整场比赛人员的能力和最高是多少. 用深搜暴力枚举每种类型的人选 ...

  2. hdu 1010 深搜+剪枝

    深度搜索 剪枝 还不是很理解 贴上众神代码 //http://blog.csdn.net/vsooda/article/details/7884772#include<iostream> ...

  3. hdu 1518 深搜

    #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #i ...

  4. hdu 1716 深搜dfs

    #include<stdio.h> #include<stdlib.h> #include<string.h> #define N 5 int f[N]; int ...

  5. hdu 5648 DZY Loves Math 组合数+深搜(子集法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5648 题意:给定n,m(1<= n,m <= 15,000),求Σgcd(i|j,i&am ...

  6. 深搜基础题目 杭电 HDU 1241

    HDU 1241 是深搜算法的入门题目,递归实现. 原题目传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1241 代码仅供参考,c++实现: #incl ...

  7. hdu 4740【模拟+深搜】.cpp

    题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...

  8. (深搜)Oil Deposits -- hdu -- 1241

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1241 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  9. hdu 1518 Square(深搜+剪枝)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1518 题目大意:根据题目所给的几条边,来判断是否能构成正方形,一个很好的深搜应用,注意剪枝,以防超时! ...

随机推荐

  1. TypeScript完全解读(26课时)_6.TypeScript完全解读-泛型

    6.TypeScript完全解读-泛型 创建实例ts文件generics.ts 在index.ts内引入 fill是填充数组,创建的数组的元素数是times,填充的值就是接收的value的值 这里传入 ...

  2. HDU - 3410 Passing the Message 单调递减栈

    Passing the Message What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flo ...

  3. 洛谷1601 A+B Problem(高精) 解题报告

    洛谷1601 A+B Problem(高精) 本题地址:http://www.luogu.org/problem/show?pid=1601 题目背景 无 题目描述 高精度加法,x相当于a+b pro ...

  4. LeetCode: 292 Nim Game(easy)

    题目: You are playing the following Nim Game with your friend: There is a heap of stones on the table, ...

  5. 1107 Social Clusters (30 分)

    When register on a social network, you are always asked to specify your hobbies in order to find som ...

  6. sql数据库查询结果字段包含换行符导致复制到Excel发生错位问题的解决

    问题描述:在工作过程中,有时会遇到这样的问题,写好sql查询语句在数据库中查询数据,看到行数(比如说是1000行),但是把查询结果复制到Excel里面,却发生了行列错位问题,而导致Excel里面的行数 ...

  7. chmod 详解

    http://man.linuxde.net/chmod chmod u+x,g+w f01 //为文件f01设置自己可以执行,组员可以写入的权限 chmod u=rwx,g=rw,o=r f01 c ...

  8. 初入Three.js 第一章

    一.什么是WebGL? 1.WebGL是在浏览器中实现三维效果的一套规范. 二.什么是threejs? 1.你将它理解成three + js就可以了.three表示3D的意思,js表示javascri ...

  9. Jquery | 基础 | .hover()

    https://api.jquery.com/hover/#hover-handlerIn-handlerOut http://jquery.cuishifeng.cn/hover.html

  10. Zynq7000开发系列-3(Xilinx交叉编译环境搭建)

    一.前言 上一篇文章说了,在开发之前必须先搭建起交叉编译环境,于是这里我们就介绍一下环境的搭建过程. 其实在所安装的Vivado HLx 2016.4中就包含了Xilinx SDK,在该SDK上即可开 ...