hdu2181
来源:互联网 发布:管理基础知识题库软件 编辑:程序博客网 时间:2024/05/17 01:20
http://acm.hdu.edu.cn/showproblem.php?pid=2181
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int map[25][5];
int vis[23];
int q[23];
int start;
int s;
void DFS(int n,int count)
{
if(count==20)
{
if(map[n][0]==start||map[n][1]==start||map[n][2]==start)
{
printf("%d: ",++s);
for(int i=0;i<20;i++)
printf("%d ",q[i]);
printf("%d\n",start);
}
}
int i;
for(i=0;i<3;i++)
{
int po=map[n][i];
if(vis[po]==0)
{
vis[po]=1;
q[count]=po;
DFS(po,count+1);
vis[po]=0;
}
}
}
int main()
{
for(int i=1;i<=20;i++)
{
scanf("%d%d%d",&map[i][0],&map[i][1],&map[i][2]);
}
while(scanf("%d",&start),start)
{
memset(vis,0,sizeof(vis));
s=0;
q[0]=start;
vis[start]=1;
DFS(start,1);
}
return 0;
}
- hdu2181
- hdu2181
- hdu2181
- HDU2181
- hdu2181
- hdu2181 dfs
- 搜索进阶 hdu2181 回溯
- hdu2181-哈密顿绕行世界
- HDU2181 哈密顿世界环游
- HDU2181:哈密顿绕行世界问题
- hdu2181哈密顿绕行世界问题(DFS)
- HDU2181:哈密顿绕行世界问题(DFS)
- HDU2181:哈密顿绕行世界问题(DFS)
- 哈密顿绕行世界问题(hdu2181)
- HDU2181---哈密顿绕行世界问题
- [dfs]hdu2181 哈密顿绕行世界问题
- 【DFS】HDU2181哈密顿绕行世界问题
- HDU2181哈密顿绕行世界问题
- java--string分析
- 程序员学习能力提升三要素
- Mysql 参数 分析
- Oracle 删除用户和表空间
- Java中的时间格式化和时间计算的方法 date calendar类详解~~~perfect
- hdu2181
- java中LinkedList 集合类实现栈和队列
- jquery 滑动
- IOS 多线程 RUNLOOP 机制 (一)
- 使用directshow代替opencv的vfw的源代码
- js为数字添加千位分隔符“,”
- Objective-C 与 C++ 的区别:
- IOS 多线程 RUNLOOP 机制 (二)
- Prime Path (p3126)