hdu 1181 深搜
2024-10-19 22:37:43
中文题
深搜
许久没写鸟,卡在输入问题上...
#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;
}
}
最新文章
- Linux进阶文件系统管理之RAID
- javascript之八——BOM
- HTML5学习总结-10 Android 控件WebView显示网页
- 1. dex和Jar反编译对比
- orcale 动态执行语句
- Jsoup开发简单网站客户端之读取本地html文件
- Java web 项目 tomcat部署方式.
- Android--Toast时间
- Oracle EBS-SQL (BOM-2):检查期间Bom的更改记录数.sql
- emwin之创建窗口与窗口回调函数的句柄是一致的
- yum upgrade卡在 清理initial-setup-0.3.9.30-1.el7.centos.x86_64
- TOP100summit【分享实录-网易】构建云直播分发网络
- Shiro学习笔记五(Shiro标签,及通配符)
- 行为类模式(四):迭代器(Iterator)
- Jquery-无法有效获取当前窗口高度
- AFO预定
- mvc 页面方法学习-RenderBody方法
- 架构-LAMP特级学习(网站大访问量解决方案)
- OpenERP how to set the tree view limit
- python学习之老男孩python全栈第九期_day017知识点总结——初识递归、算法