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 ...
随机推荐
- Node.js 内置模块Stream(流)
"流"是一种抽象的数据结构 通过使用"流"可以将一段数据分割成几段,并按顺序传输,使用"流"可以降低对系统性能的要求,减少对CPU的消耗 S ...
- nil 与 release
nil就是把一个对象的指针置为空,只是切断了指针与内存中对象的联系:而release才是真正通知内存释放这个对象. 如果没有release就直接nil,那么虽然不会出错,却等于自己制造内存泄漏了,因为 ...
- 编译出现No rule to make target `out/host/linux-x86/bin/aapt', needed by `out/target/common/obj/APPS/MyTv4_intermediates/src/R.stamp'问题
查找路径发现的确没有MyTv4_intermediates/src/R.stamp,这需要生成这个文件
- RDS 导出Mysqlbinlog_二进制日志
1:首先进入RDS后台查看Mysqlbin_log日志,可以通过以下命令进行查看: show master logs; 或 show binary logs; 2:比如我们获取的是:mysql-bin ...
- android videoView 加载等待
final Handler handler = new Handler(); Runnable runnable = new Runnable() { public void run() { int ...
- PostgreSQL-11-WITH语句
1.WITH语句原理:通用表表达式(Common Table Expressions)/CTEs,在大型查询中的辅助语句 WITH name_for_summary_data AS ( SELECT ...
- laravel-admin 配置富文本编辑器流程
laravel-admin默认去除富文本编辑器的,官方也给出了配置方法. 我配置的是wangEditor,本来配置完后就能愉快得使用了,可万万没想到还是有坑的.默认是用base64上传的,也就是数据库 ...
- [软件工程基础]2017.11.02 第六次 Scrum 会议
具体事项 燃尽图 每人工作内容 成员 已完成的工作 计划完成的工作 工作中遇到的困难 游心 #10 搭建可用的开发测试环境:#9 阅读分析 PhyLab 后端代码与文档:#8 掌握 Laravel 框 ...
- 2016级萌新选拔赛BE题
#include<bits/stdc++.h> using namespace std; #define ll long long ll a[]; ll d[]; int main() { ...
- clearfix的运行机制和进化
话说为什么要把这个记下来,因为昨天去面试,问了clearfix的原理,当时脑子不清晰,回答得真是想要咬舌自尽.遂,决定,要搞清楚来龙去脉~~~(资料来自网上博主们,)http://www.aseoe. ...