题目:

In your childhood you most likely had to solve the riddle of the house of Santa Claus. Do you remember that the importance was on drawing the house in a stretch without lifting the pencil and not drawing a line twice? As a reminder it has to look like shown in Figure 1.


Figure: The House of Santa Claus

Well, a couple of years later, like now, you have to ``draw'' the house
again but on the computer. As one possibility is not enough, we require
all the possibilities when starting in the lower left corner. Follow the example in Figure 2 while defining your stretch.


Figure: This Sequence would give the Outputline 153125432

All the possibilities have to be listed in the outputfile by increasing order, meaning that 1234... is listed before 1235... .

Output

So, an outputfile could look like this:

12435123
13245123
...
1512342 分析:
用5个点表示圣诞老人的房子,除了1-4和2-4两条边外,所有的边都相连,问能否从左下角(点1)一笔画出房子的路径有哪些,逐个点输出出来。
例如:
12435123
13245123
......
15123421
分析:
从点1开始,深搜遍历所有的边,直到遍历的边的个数达到8时递归结束。
AC code:
#include<bits/stdc++.h>
using namespace std;
int m[][];
void init()
{
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
if(i!=j) m[i][j]=;
else m[i][j]=;
}
}
m[][]=m[][]=;
m[][]=m[][]=;
}
void dfs(int e,int k,string s)
{
s+=(k+'');
if(e==)
{
cout<<s<<endl;
return;
}
for(int i=;i<=;i++)
{
if(m[k][i])
{
m[i][k]=m[k][i]=;
dfs(e+,i,s);
m[i][k]=m[k][i]=;
}
}
}
int main()
{
init();
dfs(,,"");
}

最新文章

  1. IM消息送达保证机制实现(二):保证离线消息的可靠投递
  2. string.empty和null的区别
  3. CentOS下安装LAMP环境
  4. 怎么实现ZBrush中Alt键和Shift键的灵活运用
  5. 基于gitosis的Git云端服务器配置
  6. js控制input type=checkbox 的勾选
  7. Delphi 使用之函数
  8. Java JDK 动态代理使用及实现原理分析
  9. memwatch
  10. 自动引用计数(ARC)
  11. wl18xx编译的时候出现WARNING: &quot;simple_open&quot; WARNING: &quot;wl12xx_get_platform_data&quot;
  12. 【Python初学】深copy&amp;浅copy
  13. Python_正则表达式样例
  14. WEB前端常见面试题汇总:(一)
  15. (转)Cesium教程系列汇总
  16. Spring boot配置logback
  17. Luogu P2292 [HNOI2004]L语言
  18. PyJWT 使用
  19. 模拟curl函数
  20. 移动端web开发整理

热门文章

  1. linux服务器上配置进行kaggle比赛的深度学习tensorflow keras环境详细教程
  2. mysql常用命令杂记
  3. IDA+Windbg IDA+OD 连动调试插件
  4. 123: The filename, directory name, or volume label syntax is incorrect今天玩nginx的时候报错
  5. SpringBoot(14)—注解装配Bean
  6. Python--方法/技巧在哪用的典型例子
  7. Python爬取猪肉价格网并获取Json数据
  8. AQS(抽象队列同步器)
  9. CSTC-2017-Web-writeup
  10. spark 在yarn模式下提交作业