题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5546

AC代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
const ll mod = 1e9 + ;
const int inf = 0x3f3f3f3f;
const int maxn = 5e4 + ;
int Next[][] = {{, }, {, }, {-, }, {, -}};
char str[][];
int vis[][];
bool check1(int x, int y)
{
vis[x][y] = ;
for(int i=;i<;i++)
{
int xx = x + Next[i][];
int yy = y + Next[i][];
if(xx >= && xx < && yy >= && yy < && !vis[xx][yy])
{
/* 两种情况表示在已经换了一个的情况下,还没有封死*/
if(str[xx][yy] == '.') return true;
if(str[xx][yy] == 'o' && check1(xx, yy)) return true;
}
}
return false;
}
bool check(int x, int y)
{
str[x][y] = 'x';///把点换为‘x'
bool flag= false;
for(int i=;i<;i++)
{
int xx = x + Next[i][];
int yy = y + Next[i][];
if(xx >= && xx < && yy >= && yy < )
{
if(str[xx][yy] == 'o')
{
memset(vis, , sizeof(vis));
if(!check1(xx, yy))///检查此'o'是否被封死
{
flag = true;
break;
}
}
}
}
str[x][y] = '.';///取消改换
return flag;
}
int main()
{
int t;
cin >> t;
int k = ;
while(t--)
{
for(int i=;i<;i++)
{
cin >> str[i];
}
bool flag = false;
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
if(str[i][j] == 'x' || str[i][j] == 'o') continue;
else
{
if(check(i, j))///检查是否有o的周围再加一个x可以被封死
{
flag = true;
break;
}
}
}
if(flag) break;
}
cout << "Case #" << k++ << ": ";
if(flag) cout << "Can kill in one move!!!" << endl;
else cout << "Can not kill in one move!!!" << endl;
}
return ;
}

最新文章

  1. opensuse sublime 配置
  2. WebApi Put方法出现MethodNotAllowed解决方法
  3. 1.1 让CPU占用率曲线听你指挥[cpu manager]
  4. Python使用MySQL数据库的方法以及一个实例
  5. CSS - 实现文字显示过长时用省略
  6. C++中的重载、覆盖、隐藏
  7. 10个工具让你的 shell 脚本更强大
  8. mysql中datetime和timestamp的区别
  9. ucos队列的实现--源码分析
  10. python 鸭子类型
  11. node中间层实现文件上传
  12. cpuset
  13. Android 错误提示: Can&#39;t create handler inside thread that has not called Looper.prepare()
  14. 很清晰的解读i2c协议【转】
  15. mysql中关于关联索引的问题——对a,b,c三个字段建立联合索引,那么查询时使用其中的2个作为查询条件,是否还会走索引?
  16. beta冲刺————第三天(3/5)
  17. listview点击控件显示EditText,键盘弹出消失的解决方法:
  18. localforage 对不同浏览器 使用不同的缓存策略 , 大大提高了性能 ,IndexedDB,WebSQL 和 localStorage 三种存储模式
  19. js实现loading简单的遮套层
  20. 理解Linux内核之中断控制

热门文章

  1. 微信公众号 分享接口 签名通过 分享无效果(JSSDK自定义分享接口的策略调整)
  2. asp.net WEB简单打印
  3. 湖南师范大学计算机基础课网络教学平台 版本 V2.0(2017.9.18)
  4. CPU子系统
  5. Vue项目中遇到的问题汇总
  6. Part_two:Redis之发布订阅
  7. Android Room 使用案例
  8. Vue props用法详解
  9. C#入门概述
  10. SpringBoot 中的使用事务