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 ...
随机推荐
- hadoop 2.5.1单机安装部署伪集群
环境:ubuntu 14.04 server 64版本 hadoop 2.5.1 jdk 1.6 部署的步骤主要参考了http://blog.csdn.net/greensurfer/article/ ...
- Mysql字符串截取总结及项目实际运用:left()、right()、substring()、substring_index()
在实际的项目开发中有时会有对数据库某字段截取部分的需求,这种场景有时直接通过数据库操作来实现比通过代码实现要更方便快捷些,mysql有很多字符串函数可以用来处理这些需求,如Mysql字符串截取总结:l ...
- 开源Html5+Websocket+Mqtt实时聊天室
本应用示例使用Coolpy7作为Mqtt服务器并启用Websocket代理完美支持高并发大流量即时通过能力,本示以即时通信聊天为为例.还可以应用到其他软件应用如:网页客服系统.网站信息通知.网页即时通 ...
- git合并某次提交到某个分支
有的时候,在develop分支开发,是大家公用的开发分支,但是只想合并自己提交的到master,如何操作呢?那就要用cherry-pick了. 语法 git cherry-pick commitid ...
- mvn从下载安装到纯命令行创建第一个mvn程序(编码,编译,测试,安装,打包)全过程细致分解
1.maven的下载和安装: a.maven的下载注意事项:如果你是windows,请选择①号,如果你是linux,请选择②号,下载地址:http://maven.apache.org/downloa ...
- flask_之参数传递
参数篇 request接收数据 request对象 method:当前请求方法(POST,GET等) url:当前链接地址 path:当前链接的路径 environ:潜在的WSGI环境 headers ...
- BZOJ1257(数论知识)
感觉做法很神奇……想不到啊qwq 题目: Description 给出正整数n和k,计算j(n, k)=k mod 1 + k mod 2 + k mod 3 + … + k mod n的值 其中k ...
- GDB 格式化结构体输出
转载:http://blog.csdn.net/unix21/article/details/9991925 set print addressset print address on打开地址输出,当 ...
- 修改php默认的FastCGI模式为ISAPI模式的方法
一.到www.php.net中下载PHP的ZIP文件包.注意版本要对应. 二.将sapi目录中的:php4isapi.dll复制到c:\php目录中. 三.进入虚拟主机管理平台的"网站管理& ...
- DDX_Text详细用法
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, BYTE& value ); void AFXAPI DDX_Text( CDataEx ...