题意:

Alice和Bob正在下古代围棋,规则如下:
  • 棋盘有8×8个格子,棋子下在棋盘的交叉点上,故可以有9×9个落子的位置
  • Alice执黑棋Bob执白棋轮流落子
  • 与棋子直线相连的空白交叉点叫做气。当这些气都被对方棋子占据后,该棋子就没有了“气”,要被从棋盘上提掉。如果棋子的相邻(仅上下左右)直线交叉点上有了同色的棋子,则这两个棋子被叫做相连的。任意多个棋子可以以此方式联成一体,连成一体的棋子的气的数目是所有组成这块棋的单个棋子气数之和。如果这些气都被异色棋子占领,这块棋子就要被一起提掉。
  • 当一方落子后,先检查对手的棋子,将没有“气”的对手的棋子从棋盘上提掉,再检查该方的棋子,将没有“气”的棋子提掉
现在该Alice落子,请判断Alice能否在某处落子使Bob至少有一颗棋子 被 从棋盘上提掉
析:由于格子只是9*9而已,直接枚举每个点,然后判断能不能提掉Bob的至少一个棋子即可。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 10 + 10;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
char s[maxn][maxn];
bool vis[maxn][maxn]; bool dfs(int r, int c){
if(s[r][c] == '.') return false;
vis[r][c] = 1;
for(int i = 0; i < 4; ++i){
int x = r + dr[i];
int y = c + dc[i];
if(!is_in(x, y) || vis[x][y] || s[x][y] == 'x') continue;
if(!dfs(x, y)) return false;
}
return true;
} bool solve(){
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
if(s[i][j] == 'o'){
memset(vis, 0, sizeof vis);
if(dfs(i, j)) return true;
}
return false;
} int main(){
int T; cin >> T;
for(int kase = 1; kase <= T; ++kase){
n = m = 9;
for(int i = 0; i < n; ++i) scanf("%s", s+i);
bool ok = false;
for(int i = 0; i < 9 && !ok; ++i)
for(int j = 0; j < 9 && !ok; ++j){
if(s[i][j] == '.'){
s[i][j] = 'x';
ok = solve();
s[i][j] = '.';
}
}
printf("Case #%d: %s\n", kase, ok ? "Can kill in one move!!!" : "Can not kill in one move!!!");
}
return 0;
}

  

HDU 5546 Ancient Go (搜索)的更多相关文章

  1. (hdu)5546 Ancient Go

    Problem Description Yu Zhou likes to play Go with Su Lu. From the historical research, we found that ...

  2. The 2015 China Collegiate Programming Contest G. Ancient Go hdu 5546

    Ancient Go Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  3. HDU 4616 Game (搜索)、(树形dp)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4616 这道题目数据可能比较弱,搜索都可以AC,但是不敢写,哎…… 搜索AC代码: #include & ...

  4. [HDU 2102] A计划(搜索题,典型dfs or bfs)

    A计划 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  5. hdu 4722(记忆化搜索)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 思路:简单的记忆化搜索,留意一下A==0时的情况就可以了. #include<iostre ...

  6. hdu 1010(迷宫搜索,奇偶剪枝)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1010 Tempter of the Bone Time Limit: 2000/1000 MS (Ja ...

  7. hdu 5335 Walk Out (搜索)

    题目链接: hdu 5335 Walk Out 题目描述: 有一个n*m由0 or 1组成的矩形,探险家要从(1,1)走到(n, m),可以向上下左右四个方向走,但是探险家就是不走寻常路,他想让他所走 ...

  8. HDU 1896 Stones --优先队列+搜索

    一直向前搜..做法有点像模拟.但是要用到出队入队,有点像搜索. 代码: #include <iostream> #include <cstdio> #include <c ...

  9. HDU 1978 记忆化搜索(dfs+dp)

    Y - How many ways Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. iOS怎样获取任何App的资源图片?

    1.打开iTunes,并与手机相连接 2.按照下图所示执行搜索并下载App 3.到Mac的 /Users/apple/Music/iTunes/iTunes Media/Mobile Applicat ...

  2. PCA tries to preserve linear structure, MDS tries to preserve global geometry, and t-SNE tries to preserve topology (neighborhood structure)

    https://colah.github.io/posts/2014-10-Visualizing-MNIST/

  3. mysq'l系列之10.mysql优化&权限控制

    网站打开慢如何排查 1.打开网页, 用谷歌浏览器F12, 查看network: 哪个加载时间长就优化哪个 2.如果是数据库问题 2.1 查看大体情况 # top # uptime  //load av ...

  4. CSS各种度量单位----px、em、%、rem、vh/vw、vmin/vmax

    本文主要讲下CSS中各类度量单位的意思和区别. 开发中最常用到的css单位是px.em.%.随着css3的出现,带来了更多的度量单位,这些单位为响应式开发,带来很大的好处.各种单位的浏览器兼容性可以去 ...

  5. 我的Android进阶之旅------>Android如何通过自定义SeekBar来实现视频播放进度条

    首先来看一下效果图,如下所示: 其中进度条如下: 接下来说一说我的思路,上面的进度拖动条有自定义的Thumb,在Thumb正上方有一个PopupWindow窗口,窗口里面显示当前的播放时间.在Seek ...

  6. 相比ICO,DAICO主要有这两方面优势

    都说ICO已死,很有一部分人对无币区块链持保留态度,自从V神提出DAICO一来,大家似乎看到了新的方向,不少项目围绕其展开.那对比ICO,DAICO有哪些优势呢?主要是以下两点: DAICO维护了投资 ...

  7. selector + drawable 多状态图形

    select_drawble.xml<?xml version="1.0" encoding="utf-8"?> <selector xmln ...

  8. Database: key

    super-key: Any key that has more columns than necessary to uniquely identify each row in the table i ...

  9. ubuntu部分常用操作指令记录

    # 以ROOT权限打开图形文件管理界面: sudo nautilus # 给某个文件添加可执行权限,例如: sudo chmod +x /usr/lib/jdk/bin/java # 修改某个文件或文 ...

  10. 学习 Promise,掌握未来世界 JS 异步编程基础

    其实想写 Promise 的使用已经很长时间了.一个是在实际编码的过程中经常用到,一个是确实有时候小伙伴们在使用时也会遇到一些问题.Promise 也确实是 ES6 中 对于写 JS 的方式,有着真正 ...