UVa 291 The House Of Santa Claus——回溯dfs
题意:从左下方的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的更多相关文章
- UVA 291 The House Of Santa Claus(DFS算法)
题意:从 节点1出发,一笔画出 圣诞老人的家(所谓一笔画,就是遍访所有边且每条边仅访问一次). 思路:深度优先搜索(DFS算法) #include<iostream> #include&l ...
- 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 ...
- UVA 291 The House Of Santa Claus (DFS求一笔画)
题意:从左下方1开始,一笔画出圣诞老人的屋子(不过话说,圣诞老人的屋子是这样的吗?这算是个屋子么),输出所有可以的路径. 思路:贴代码. #include <iostream> #incl ...
- codeforces 748E Santa Claus and Tangerines
E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- linux 搭建unixODBC ,并对接 PostgreSQL 9.3.4
环境:suse 11 ,64位的操作系统 unixODBC 版本:2.3.2 PostgreSQL 9.3.4 1 编译安装 unixODBC 下载 unixODBC :http://www.unix ...
- 后台管理系统·快速开发框架JSite
平台介绍 框架基于Maven构建,拆分成多个子模块,层次结构清晰.可用于所有Web应用,如企业后台管理系统.OA系统.CMS.CRM等. 框架本身集成了最新的 Flowable工作流引擎 https: ...
- struts2与struts1的比较
struts2相对于struts1来说简单了很多,并且功能强大了很多,我们可以从几个方面来看: 从体系结构来看:struts2大量使用拦截器来出来请求,从而允许与业务逻辑控制器 与 servlet-a ...
- 小程序video置顶
page { overflow-y: none; height: 100vh; } .page__hd_media { position: fixed; width:100vw; top:; heig ...
- Sql 2000系统表 语句查询表结构
SQL2000系统表的应用 –1:获取当前数据库中的所有用户表 select Name from sysobjects where xtype=’u’ and status>=0 –2:获取 ...
- 正则表达式匹配URL——给URL地址加上<a> 链接
<?php function replace_url ($content) { if (empty($content)) return; //给URL地址加上 <a> 链接 $pre ...
- vs2013修改为双击打开文件
vs2012和vs2013默认是单击打开文件,让人突然就不习惯了,各种不爽. 修改方法: 工具-选项-环境-选项卡和窗口-不勾选允许在预览选项卡中打开新文件.
- Java-IDEA环境搭建swagger
1.项目POM导入包(使用Maven管理的代码) 2.POM文件导入包 <dependencyManagement> <dependencies> <dependency ...
- js将数字转换为带有单位的中文表示
好不容易找到了, 实测可行, 记录一下. 到时候调用方法 addChineseUnit , 其他两个方法在addChineseUnit中有调用 /** * 为数字加上单位:万或亿 * * 例如 ...
- github入门之创建仓库--3
1.登陆到github,点击加号中的New repository 2.设置仓库信息 *注: ------Description:添加仓库说明,不是必填项 ------Public.Private:选择 ...