URAL.1033 Labyrinth (DFS)
来源:互联网 发布:足球战术 软件 编辑:程序博客网 时间:2024/06/07 14:55
URAL.1033 Labyrinth (DFS)
题意分析
WA了好几发,其实是个简单地DFS。意外发现这个俄国OJ,然后发现ACRUSH把这个OJ刷穿了。
代码总览
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <sstream>#include <set>#include <map>#include <queue>#include <stack>#include <cmath>#define INF 0x3f3f3f3f#define nmax 35#define MEM(x) memset(x,0,sizeof(x))using namespace std;int spx[] = {0,1,0,-1};int spy[] = {1,0,-1,0};char mp[35][35];bool visit[35][35];int n,ans;void dfs(int x,int y){ for(int i=0;i<4;i++){ int nx = x + spx[i]; int ny = y +spy[i]; if(!visit[nx][ny] && mp[nx][ny]=='.'){ visit[nx][ny] = true; dfs(nx,ny); } else if(mp[nx][ny]=='#') ans++; }}int main(){ //freopen("in.txt","r",stdin); while(scanf("%d",&n)!= EOF){ ans = 0; memset(mp,'#',sizeof(mp)); for(int i=1;i<=n;i++){ scanf("%s",mp[i]+1); mp[i][n+1] = '#'; } visit[1][1] = true; dfs(1,1); if(!visit[n][n]){ visit[n][n] = true; dfs(n,n); } printf("%d\n",(ans-4)*9); } return 0;}
0 0
- URAL 1033 Labyrinth(DFS)
- URAL 1033 Labyrinth (DFS)
- URAL.1033 Labyrinth (DFS)
- ural 1033. Labyrinth(dfs)
- ural 1033. Labyrinth dfs
- ural 1033. Labyrinth dfs
- ural 1033 Labyrinth
- Labyrinth (URAL 1033)
- URAL 1033|Labyrinth|搜索
- Ural 1033 Labyrinth(bfs)
- 【Ural 1033】 Labyrinth.(迷宫)
- ural 1033. Labyrinth
- POJ 2357 Labyrinth [DFS]
- The Labyrinth (dfs)
- URAL - 1145 Rope in the Labyrinth
- CF 616C The Labyrinth(dfs)
- CodeForces 616 C. The Labyrinth(dfs)
- codeforces 616C The Labyrinth (dfs)
- JS解析Json中List类型,并遍历List中的对象
- 仿美团详情滑动界面,并兼容NestedScroll嵌套
- JMeter学习笔记1-安装环境
- 模拟ExtJS底层继承(原理)
- 1个鼠标和1个键盘控制2台电脑(windows和linux系统)
- URAL.1033 Labyrinth (DFS)
- 【网络爬虫】HttpClient抓取+解析+存储数据
- hive常用命令
- Codeforces803A Maximal Binary Matrix
- STL顺序容器vector,list和deque
- 集合运算(完成集合的并、交、差(输出被减集合的剩余元素))
- C++11 lambda 表达式解析
- 【leetcode】binary-tree-preorder-traversal
- JavaScript的严格模式