迷宫问题
来源:互联网 发布:淘宝死店还能活吗 编辑:程序博客网 时间:2024/05/21 06:47
const maxn=8; dx:array[0..maxn] of integer=(0,-1,-1,-1,0,1,1,1,0); dy:array[0..maxn] of integer=(0,-1,0,1,1,1,0,-1,-1);var n,s,total:integer; a:array[0..maxn+1,0..maxn+1] of 0..1; b:array[0..maxn*maxn] of integer;procedure init; var i,j:integer;begin readln(n); for i:=1 to n do begin for j:=1 to n do read(a[i,j]); readln; end; s:=0;total:=0;a[1,1]:=1;end;procedure print; var i,x,y:integer; begin inc(total); x:=1;y:=1; for i:=1 to s-1 do begin x:=x+dx[b[i]]; y:=y+dy[b[i]]; end; x:=x+dx[b[s]];y:=y+dy[b[s]]; end;procedure search(x,y:integer); var i,sx,sy:integer; begin if (x=1) and (y=n) then begin print; exit; end; for i:=1 to maxn do if (x+dx[i] in [1..n]) and (y+dy[i] in [1..n]) and (a[x+dx[i],y+dy[i]]=0) then begin inc(s); b[s]:=i; a[x+dx[i],y+dy[i]]:=1; search(x+dx[i],y+dy[i]); dec(s); a[x+dx[i],y+dy[i]]:=0; end; end;begin init; search(1,1); writeln(total);end.
0 0
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题...
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- 迷宫问题
- iOS 开发缓存机制之一内存缓存机制
- 做的最简单的APP-计数器
- Failed to resolve: com.android.support.fragment_mine.espresso:espresso-core:2.2.2
- [LeetCode]Surrounded Regions
- 编译原理作业3,4
- 迷宫问题
- cenos 7 上安装phpmyadmin
- Unity3D工具类 - soomla支付接口
- shell 学习杂记一
- android启动应用得 Uri.parse(path + projct + ".apk"), "application/and.and.package-archive"
- c#中自定义集合的实现
- linux(ubuntu) 安裝solr6.3 在tomcat8上 創建core
- 2016河海大学程序设计大赛专业组题解 快速幂取模 博弈论 背包 floyd
- 测试开发之----给你的apk加上时间分片的log记录