Ancient Go---hdu5546(dfs爆搜CCPC题目)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5546
题意就是两个人下围棋,问在下一颗x是否能杀死o,'.'是空位子;
枚举所有的点,判断是否合法即可;
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <math.h> using namespace std; #define met(a, b) memset(a, b, sizeof(a))
#define N 103
#define INF 0x3f3f3f3f typedef long long LL; int dir[][] = { {,}, {-,}, {,-}, {,} };
char s[N][N];
int vis[N][N]; int OK(int x, int y)
{
return (x< && y< && x>= && y>=);
} int check(int x, int y)
{
vis[x][y] = ;
for(int i=; i<; i++)
{
int px = x+dir[i][];
int py = y+dir[i][];
if(!OK(px, py) || vis[px][py])continue;
if(s[px][py] == '.')
return ;
if(s[px][py] == 'o' && check(px, py))
return ;
}
return ;
} int Judge(int x, int y)
{
for(int i=; i<; i++)
{
int px = x + dir[i][];
int py = y + dir[i][];
if(!OK(px, py))continue;
if(s[px][py] == 'o')
{
met(vis, );
if(!check(px, py))
return ;///不能走出去说明找到了;
}
}
return ;
} int solve()
{
for(int i=; i<; i++)
{
for(int j=; j<; j++)
{
if(s[i][j] == 'x' || s[i][j] == 'o')continue;
s[i][j] = 'x';
if(Judge(i, j))return ;
s[i][j] = '.';
}
}
return ;
} int main()
{
int T, t = ;
scanf("%d", &T);
while(T--)
{
for(int i=; i<; i++)
{
scanf("%s", s[i]);
}
int ans = solve();
if(ans) printf("Case #%d: Can kill in one move!!!\n", t++);
else printf("Case #%d: Can not kill in one move!!!\n", t++);
}
return ;
}
Ancient Go---hdu5546(dfs爆搜CCPC题目)的更多相关文章
- HDU 4403 A very hard Aoshu problem(dfs爆搜)
http://acm.hdu.edu.cn/showproblem.php?pid=4403 题意: 给出一串数字,在里面添加一个等号和多个+号,使得等式成立,问有多少种不同的式子. 思路: 数据量比 ...
- POJ3185 The Water Bowls(反转法or dfs 爆搜)
POJ3185 The Water Bowls 题目大意: 奶牛有20只碗摆成一排,用鼻子顶某只碗的话,包括左右两只在内的一共三只碗会反向,现在给出碗的初始状态,问至少要用鼻子顶多少次才能使所有碗都朝 ...
- hdu 5506 GT and set(dfs爆搜)
Problem Description You are given N sets.The i−th set has Ai numbers.You should divide the sets into ...
- 【BZOJ-1060】时态同步 树形DP (DFS爆搜)
1060: [ZJOI2007]时态同步 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2101 Solved: 595[Submit][Statu ...
- hdu 4770(枚举 + dfs爆搜)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4770 思路:由于最多只有15个".",可以直接枚举放置的位置,然后判断是否能够全部 ...
- 火车进栈(进出栈的模拟,dfs爆搜)
这里有n列火车将要进站再出站,但是,每列火车只有1节,那就是车头. 这n列火车按1到n的顺序从东方左转进站,这个车站是南北方向的,它虽然无限长,只可惜是一个死胡同,而且站台只有一条股道,火车只能倒着从 ...
- 【csp模拟赛2】 爆搜 方格加数
[题目描述] xyz1048576正在玩一个关于矩阵的游戏. 一个n*m的矩阵,矩阵中每个数都是[1,12]内的整数.你可以执行下列两个操作任意多次: (1)指定一行,将该行所有数字+1. (2)指定 ...
- 2015 UESTC 搜索专题C题 基爷与加法等式 爆搜DFS
基爷与加法等式 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/61 Desc ...
- USACO1.6 Healthy Holsteins【dfs/bfs 爆搜】
题目传送门 饲料种数只有15 枚举每种选或不选一共也就只有$2^{15}=32768$ 爆搜可过觉得bfs要快一些? 但是dfs更方便处理字典序 只需要顺序遍历并且先搞选它的情况就可以了 而且在这种规 ...
随机推荐
- scala中to和util操作
// Range:to:默认步进为1 val to1 = 1 to 10 println(to1) // 定义一个不进为2的Range val to2 = 1 to 10 by 2 println(t ...
- 【代码审计】CLTPHP_v5.5.3后台任意文件下载漏洞分析
0x00 环境准备 CLTPHP官网:http://www.cltphp.com 网站源码版本:CLTPHP内容管理系统5.5.3版本 程序源码下载:https://gitee.com/chich ...
- RF判断列表、字典、整数、字符串类型是否相同方法
${d} create list shk shsh${w} create list ${e} evaluate type(${d}) ${t} evaluate type(${w}) should ...
- Splash Lua 脚本
Splash 可以通过 Lua 脚本执行一系列渲染操作,这样我们就可以用 Splash 来模拟浏览器的操作了,Splash Lua 基础语法如下: function main(splash, args ...
- C++ template —— tuple(十三)
本系列博文中我们使用同类容器(如数组类型)来阐述模板的强大威力,同时,C/C++还具有包含异类对象的能力.这里的异类指的是类型不同,或者结构不同.tuple就是这样的一个类模板,它能够用于聚集不同类型 ...
- html/php/mysql乱码
1. html通过jquery的ajax传递数据给php. encodeURI("my.php?name=博客园") 2. php接受 urldecode($_GET[" ...
- javascript/css压缩工具---yuicompressor使用方法
1. 下载 地址:https://github.com/yui/yuicompressor/downloads 2. 安装 yuicompressor是由java写成的一组jar文件,需要jdk环境支 ...
- 【LeetCode OJ】Add Two Numbers
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in re ...
- React Native 入门到原理(详解)
抛砖引玉(帮你更好的去理解怎么产生的 能做什么) 砖一.动态配置 由于 AppStore 审核周期的限制,如何动态的更改 app 成为了永恒的话题.无论采用何种方式,我们的流程总是可以归结为以下三部曲 ...
- 【Linux】 解决报错: ImportError: libSM.so.6: cannot open shared object file: No such file or directory
centos7 + python3.6.4 我使用 pip3 install opencv-python 安装了opencv-python 之后,在使用 import cv2 报错如下 报错原因 ...