当前位置:网站首页>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;
}
边栏推荐
- Thinkphp3.2 information disclosure
- Netease Cloud Wechat applet
- Communication mode between processes
- asp. How to call vb DLL function in net project
- 如何成为一名高级数字 IC 设计工程师(1-6)Verilog 编码语法篇:经典数字 IC 设计
- In fact, it's very simple. It teaches you to easily realize the cool data visualization big screen
- Schema-validation: wrong column type encountered in column XXX in table XXX
- [4G/5G/6G专题基础-146]: 6G总体愿景与潜在关键技术白皮书解读-1-总体愿景
- 用flinksql的方式 写进 sr的表,发现需要删除的数据没有删除,参照文档https://do
- Unity3d interface is embedded in WPF interface (mouse and keyboard can respond normally)
猜你喜欢
# Arthas 简单使用说明
农牧业未来发展蓝图--垂直农业+人造肉
使用BigDecimal的坑
csdn涨薪技术-浅学Jmeter的几个常用的逻辑控制器使用
Nested (multi-level) childrn routes, query parameters, named routes, replace attribute, props configuration of routes, params parameters of routes
Vs2013 generate solutions super slow solutions
NATAPP内网穿透
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
基于智慧城市与储住分离数字家居模式垃圾处理方法
Lecture 1: stack containing min function
随机推荐
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
Can flycdc use SqlClient to specify mysqlbinlog ID to execute tasks
牛客网——华为题库(61~70)
洛谷P2482 [SDOI2010]猪国杀
其实特简单,教你轻松实现酷炫的数据可视化大屏
How to solve the problem of golang select mechanism and timeout
Esp8266 uses TF card and reads and writes data (based on Arduino)
JS reverse tutorial second issue - Ape anthropology first question
Oracle installation enhancements error
VSCode+mingw64
创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。
HCIP 第一天 笔记整理
iNFTnews | 时尚品牌将以什么方式进入元宇宙?
Mysql:select ... for update
细说Mysql MVCC多版本控制
Information Security Experiment 2: using x-scanner scanning tool
如何成为一名高级数字 IC 设计工程师(5-3)理论篇:ULP 低功耗设计技术精讲(下)
大佬们,有没有遇到过flink cdc读MySQLbinlog丢数据的情况,每次任务重启就有概率丢数
La différence entre viewpager 2 et viewpager et la mise en œuvre de la rotation viewpager 2
[bw16 application] Anxin can realize mqtt communication with bw16 module / development board at instruction