题意:从左下方的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. [Xcode 实际操作]七、文件与数据-(22)使用OCR光学字符识别技术识别银行卡号码

    目录:[Swift]Xcode实际操作 本文将演示如何使用光学字符识别技术,识别信用卡上的卡号. OCR技术是光学字符识别的缩写(Optical Character Recognition), 是通过 ...

  2. MySQL习题1 一对多实例 产品和分类

    /* 需求:建立产品和分类表 1.查询每种分类的产品数量,没有产品的分类也要统计.(cname,quantity) 2.根据分类名称查询分类中的所有产品 */ -- ----------------- ...

  3. 简单的Javascript图片延迟加载库Echo.js

    简介: 和 Lazy Load 一样,Echo.js 也是一个用于图像延迟加载 JavaScript.不同的是 Lazy Load 是基于 jQuery 的插件,而 Echo.js 不依赖于 jQue ...

  4. C# 基础之构造函数

    什么是构造函数? 构造函数主要用于创建类的实例对象,当调用一个构造函数创建对象时,构造函数会为对象分配内存空间并初始化类的成员. 构造函数分为:1.实例构造函数.2.静态构造函数 1.实例构造函数 使 ...

  5. DISTINCT 去重---SQL

    SQL SELECT DISTINCT 语句 在表中,一个列可能会包含多个重复值,有时您也许希望仅仅列出不同(distinct)的值. DISTINCT 关键词用于返回唯一不同的值. SQL SELE ...

  6. 缺少mscvr100.dll

    最后使用百度电脑专家修复好的!

  7. ubuntu dpkg命令总结

    dpkg是Debian系统的后台包管理器,类似RPM.也是Debian包管理系统的中流砥柱,负责安全卸载软件包,配置,以及维护已安装的软件包.由于ubuntu和Debian乃一脉相承,所以很多命令是不 ...

  8. B. Dispersed parentheses 记忆化搜索 + 括号序列的状压表示

    http://codeforces.com/gym/100633/problem/B B. Dispersed parentheses time limit per test 2 seconds me ...

  9. object-position和object-fit

    今天在用video标签时发现改变video的宽和高,它里面播放内容由于比例的限制无法充满我设置的宽高,这时要是有类似background-size属性该是多好.网上一查果然找到了css3中的objec ...

  10. nodejs express 设置html后缀模板

    express 框架的默认渲染模板的后缀是 ejs ,由于编译器在ejs的文件里写html代码没有高亮显示,所以使用html模板. 示例: var app = express(); app.set(' ...