UVA291_The House Of Santa Claus(DFS)
来源:互联网 发布:office2016破解软件 编辑:程序博客网 时间:2024/05/01 05:58
The House Of Santa Claus
In your childhood you most likely had to solve the riddle of the house of Santa Claus. Do you remember that the importance was on drawing the house in a stretch without lifting the pencil and not drawing a line twice? As a reminder it has to look like shown in Figure 1.
Figure: The House of Santa Claus
Well, a couple of years later, like now, you have to ``draw'' the house again but on the computer. As one possibility is not enough, we require all the possibilities when starting in the lower left corner. Follow the example in Figure 2 while defining your stretch.
Figure: This Sequence would give the Outputline 153125432
All the possibilities have to be listed in the outputfile by increasing order, meaning that 1234... is listed before 1235... .
Output
So, an outputfile could look like this:
1243512313245123...15123421解题报告
计算从节点1出发的所有可能访问序列,要求按节点递增序列输出
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;int mmap[6][6];int vis[6][6];void dfs(int x,int cnt,string str){ str+=char(x+'0'); if(cnt==8) { cout<<str; cout<<endl; return; } for(int i=1;i<=5;i++) { if(mmap[x][i]&&!vis[x][i]) { vis[x][i]=vis[i][x]=1; dfs(i,cnt+1,str); vis[x][i]=vis[i][x]=0; } }}int main(){ for(int i=1;i<=5;i++) { for(int j=1;j<=5;j++) mmap[i][j]=1; mmap[i][i]=0; } mmap[1][4]=mmap[4][1]=mmap[2][4]=mmap[4][2]=0; dfs(1,0,""); return 0;}
- UVA291_The House Of Santa Claus(DFS)
- The House Of Santa Claus(dfs)
- UVA 291 The House Of Santa Claus(DFS算法)
- UVA 291 The House Of Santa Claus(DFS/深搜)
- uva 291 The house of santa claus DFS
- The House Of Santa Claus
- The House Of Santa Claus
- UVa 291 - The House Of Santa Claus
- uva 291The House Of Santa Claus
- 291 - The House Of Santa Claus
- (DFS11.2.1)UVA 291 The House Of Santa Claus(使用DFS来解决一笔画问题)
- UVA 291 The House Of Santa Claus 图的遍历
- (深度搜索)The House Of Santa Claus
- Santa Claus
- Santa claus would not come~
- Codeforces753A Santa Claus and Candies
- codeforces748c-Santa Claus and Robot
- 【codeforces 752C】Santa Claus and Robot
- Linux系统对IO端口和IO内存的管理
- Given an array of integers, every element appears twice except for one. Find that single one.
- 使用共用体存储各类型数据到EEPROM
- 安卓开发sdk选择和兼容问题
- spring的controller默认是单例还是多例
- UVA291_The House Of Santa Claus(DFS)
- Android平台上做一个完美的音乐频谱--Music Audio Glow
- opencv操作每个像素
- [LeetCode]Longest Consecutive Sequence
- Unreal SDK 游戏开发从入门到精通视频教程
- UIViewController连续push、pop的正确做法
- 剑指offer面试题10
- Sublime Text常用快捷命令整理
- android设备计算密度,宽高!