题意:从左下方的1开始,一笔画出圣诞老人的房子。

 #include <iostream>
#include <cstring>
using namespace std;
int edge[][]; //已画了k条边 准备将端点x加入进来
void dfs(int x,int k,string s){
s+=char(x+'');
if(k==){
cout<<s<<endl;
return;
}
for(int y=;y<=;y++){
if(edge[x][y]){
edge[x][y]=edge[y][x]=;
dfs(y,k+,s);
edge[x][y]=edge[y][x]=;
}
}
}
int main(){
memset(edge,,sizeof(edge));
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(i!=j)
edge[i][j]=;
}
}
edge[][]=edge[][]=;//1、4 2、4不相连
edge[][]=edge[][]=;
dfs(,,"");
return ;
}

UVa 291 The House Of Santa Claus——回溯dfs的更多相关文章

  1. UVA 291 The House Of Santa Claus(DFS算法)

    题意:从 节点1出发,一笔画出 圣诞老人的家(所谓一笔画,就是遍访所有边且每条边仅访问一次). 思路:深度优先搜索(DFS算法) #include<iostream> #include&l ...

  2. UVA 291 The House Of Santa Claus DFS

    题目: In your childhood you most likely had to solve the riddle of the house of Santa Claus. Do you re ...

  3. UVA 291 The House Of Santa Claus (DFS求一笔画)

    题意:从左下方1开始,一笔画出圣诞老人的屋子(不过话说,圣诞老人的屋子是这样的吗?这算是个屋子么),输出所有可以的路径. 思路:贴代码. #include <iostream> #incl ...

  4. codeforces 748E Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  5. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL

    D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...

  6. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  7. Codeforces Round #389 Div.2 E. Santa Claus and Tangerines

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  8. Codeforces Round #389 Div.2 D. Santa Claus and a Palindrome

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. Codeforces Round #389 Div.2 C. Santa Claus and Robot

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

随机推荐

  1. 多次页面跳转后pop回主界面的问题

    最近写代码的时候出了点BUG, 查阅资料后终于解决了. 问题原因大概是: 项目中所有的viewController都是继承自一个封装好的viewController. navigationbar, n ...

  2. XML标准和RFC官方文档

  3. Map集合的四种常用遍历方式整理

    1.Map集合简介:map集合是一个key—value型的数据结构,存储的数据具有查询速度快速的特点,但由于是无序的,所以没有顺序可言.在遍历时没有办法像简单的list或数组一样. 2.代码: pac ...

  4. [POI2011]Plot

    https://szkopul.edu.pl/problemset/problem/mzrTn1kzVBOAwVYn55LUeAai/site/?key=statement 既卡常又卡精度...真的A ...

  5. 异步加载js文件的方法

    # 异步加载js文件 - js的加载默认是同步的,因为js是单线程执行,只能完成一件再执行下一件. - 一些外部引入的js文件可以因为文件太大,在加载资源的过程中会影响dom元素的加载,影响了用户体验 ...

  6. Parenthesis UVALive - 4882 删除不必要的括号序列,模拟题 + 数据

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  7. centos7安装文档

    1.当载入安装镜像时,我们会看到如下图中的画面,我们选择第一项,安装centos7 2.选择英语(个人测试环境可以使用中文安装) 3.选择network&hostname配置网络 4.在配置网 ...

  8. bootstrap基本组件

    bootstrap分页   <nav>      <ul class="pagination">       <li><a href=&q ...

  9. Java语言中自动生成随机数

    参考原文:http://zhidao.baidu.com/link?url=nB3BT69wmUAiSPfKGgK5Q7HOFFP9AIE04AthreRd9yYcwKhUQsQRWlMdMhW1Qm ...

  10. 使用vscode软件运行zebrajs框架小结

    最近在研究使用zebrajs框架,用vscode编辑器进行开发.vsc这个编辑器说起来还是很强大的,就是支持各种系统的多种语言开发.用于前端的话可以直接在编辑器上边调试javascript,就是需要n ...