当前位置:网站首页>14th test
14th test
2022-07-07 09:47:00 【moyangxian】
#include<iostream>
using namespace std;
const int N=1010;
int g[N][N]={
{
1, 1, 1, 1, 1, 1 },
{
1, 0, 0, 0, 1, 1 },
{
1, 0, 1, 0, 0, 1 },
{
1, 0, 0, 0, 1, 1 },
{
1, 1, 0, 0, 0, 1 },
{
1, 1, 1, 1, 1, 1 }
};
bool vis[N][N];
struct Node{
int x,y;
}ans[N];
int cnt;
int dis[][2]={
0,1,1,0,0,-1,-1,0};
bool check(int x,int y){
if(vis[x][y]||g[x][y]==1) return true;
return false;
}
void dfs(int x,int y,int p){
ans[p]={
x,y};
if(x==4&&y==4){
cout<<" Maze path "<<++cnt<<":"<<endl;
for(int i=1;i<=p;i++){
cout<<'('<<ans[i].x<<','<<ans[i].y<<") ";
}
cout<<endl;
return ;
}
for(int i=0;i<4;i++){
int xx=x+dis[i][0];
int yy=y+dis[i][1];
if(check(xx,yy)) continue;
vis[xx][yy]=true;
dfs(xx,yy,p+1);
vis[xx][yy]=false;
}
}
int main(){
cout<<" Maze corresponding adjacency table "<<endl;
for(int i=0;i<=5;i++){
for(int j=0;j<=5;j++){
cout<<'['<<i<<','<<j<<"]:";
if(i==0||j==0||i==5||j==5){
cout<<endl;
continue;
}
for(int k=0;k<4;k++){
int xx=i+dis[k][0];
int yy=j+dis[k][1];
if(check(xx,yy)) continue;
cout<<'('<<xx<<','<<yy<<')'<<"\t";
}
cout<<endl;
}
}
cout<<" The path of all mazes :"<<endl;
vis[1][1]=true;
dfs(1,1,1);
return 0;
}
边栏推荐
- Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion
- Addition, deletion, modification and query of ThinkPHP database
- Software modeling and analysis
- La différence entre viewpager 2 et viewpager et la mise en œuvre de la rotation viewpager 2
- How to use Mongo shake to realize bidirectional synchronization of mongodb in shake database?
- 其实特简单,教你轻松实现酷炫的数据可视化大屏
- Impression notes finally support the default markdown preview mode
- Lesson 1: hardness of eggs
- Nested (multi-level) childrn routes, query parameters, named routes, replace attribute, props configuration of routes, params parameters of routes
- How to become a senior digital IC Design Engineer (5-3) theory: ULP low power design technology (Part 2)
猜你喜欢
Vs2013 generate solutions super slow solutions
NATAPP内网穿透
小程序滑动、点击切换简洁UI
Dynamics 365online applicationuser creation method change
12、 Sort
What development models did you know during the interview? Just read this one
ComputeShader
csdn涨薪技术-浅学Jmeter的几个常用的逻辑控制器使用
印象笔记终于支持默认markdown预览模式
H5 web player easyplayer How does JS realize live video real-time recording?
随机推荐
CMD startup software passes in parameters with spaces
How to become a senior digital IC Design Engineer (1-6) Verilog coding Grammar: Classic Digital IC Design
H5 web player easyplayer How does JS realize live video real-time recording?
消费互联网的产业链其实是很短的,它仅仅承接平台上下游的对接和撮合的角色
The configuration and options of save actions are explained in detail, and you won't be confused after reading it
Unity shader (pass user data to shader)
哈夫曼编码压缩文件
进程和线程的区别
What development models did you know during the interview? Just read this one
Nested (multi-level) childrn routes, query parameters, named routes, replace attribute, props configuration of routes, params parameters of routes
Unity3d interface is embedded in WPF interface (mouse and keyboard can respond normally)
进程间的通信方式
js逆向教程第二发-猿人学第一题
Liunx command
Use 3 in data modeling σ Eliminate outliers for data cleaning
How to use Mongo shake to realize bidirectional synchronization of mongodb in shake database?
ViewPager2和VIewPager的區別以及ViewPager2實現輪播圖
Database multi table Association query problem
Natapp intranet penetration
The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart