hdu 5546 Ancient Go(2016ccpc) 暴力DFS
来源:互联网 发布:淘宝包包拍摄技巧 编辑:程序博客网 时间:2024/06/05 17:35
传送门:[hdu 5546 Ancient Got](http://acm.hdu.edu.cn/showproblem.php?pid=5884
解题思路
先找到对方的棋子也就是’o’点,然后判断对方点旁边的’.’是不是大于1如果大于1是肯定不行的,否则就是正确的!
AC代码
#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int MX = 15;char maze[MX][MX];bool vis[MX][MX];int dirX[] = {0,0,1,-1};int dirY[] = {1,-1,0,0};int ret;void DFS(int r,int c){ vis[r][c] = true; for(int i=0;i<4;i++) { int xx = r + dirX[i]; int yy = c + dirY[i]; if(xx<0||xx>8||yy<0||yy>8||vis[xx][yy]||maze[xx][yy]=='x') continue; if(maze[xx][yy]=='.') { vis[xx][yy] = true; ret++; continue; } DFS(xx,yy); }}bool solve(){ for(int i=0;i<=8;i++) { for(int j=0;j<=8;j++) { if(maze[i][j]=='o') { ret = 0; memset(vis,false,sizeof vis); DFS(i,j); if(ret<2) return true; } } } return false;}int main(void){ int T;//freopen("in.txt","r",stdin); cin>>T; for(int cas=1;cas<=T;cas++) { for(int i=0;i<=8;i++) scanf("%s",maze[i]); printf("Case #%d: %s\n",cas,solve()?"Can kill in one move!!!":"Can not kill in one move!!!"); }}
0 0
- hdu 5546 Ancient Go(2016ccpc) 暴力DFS
- 2015 南阳 CCPC hdu 5546 Ancient Go(DFS,暴力)
- HDU~5546 Ancient Go(暴力dfs)
- Ancient Go【ccpc dfs】
- HDU 5546 Ancient Go(DFS)
- HDU 5546 Ancient Go (dfs)
- hdu 5546 Ancient Go(dfs)
- 【dfs】hdu 5546 Ancient Go
- HDU 5546 Ancient Go (dfs)
- hdu 5546 Ancient Go(dfs)
- HDU5546 Ancient Go(深搜DFS)(2015CCPC)
- hdu 5546 Ancient Go【dfs】【思维】
- HDU 5546 Ancient Go——dfs
- hdu 5546 Ancient Go 枚举 DFS
- 2015 CCPC Ancient Go
- ccpc Ancient Go(dfs求连通块周围'.'的数目)
- hdu 5546 Ancient Go
- HDU 5546 Ancient Go
- Linux总结(四):vim文本编辑器
- Sass 学习笔记
- 序列化二叉树
- 第三周项目2-建设“顺序表”算法库
- sizeof(程序员求职宝典)
- hdu 5546 Ancient Go(2016ccpc) 暴力DFS
- 矩阵键盘
- vim插件管理利器:pathogen
- 新的开始~加油
- 实验任务3 理解Task
- linux设置网卡速率
- Espresso 不依赖源代码的测试
- Android 下载文件 进度条显示
- docker