题目链接:http://acm.zzuli.edu.cn/zzuliacm/problem.php?id=1908

题意:如果'.'被'*'围起来,就把'.'变为'*'。

分析:如果是'*'直接输出,如果是'.' 则要对其搜索

如果四个方向都是封闭的,则可以改变。即w[i][j]=4;

如果查询的是'*'或者查询的是已被查询过的'.'  ,则记录上;

如果查询的是'.'而且没有查询标记过,则进行查询;

 #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath> using namespace std; #define N 50
#define INF 0x3f3f3f3f char s[N][N];
int w[N][N],b[N][N],n,m;
int dir[][]= { {,},{,},{-,},{,-} }; int q(int x,int y)
{
int i; b[x][y]=;
for(i=; i<; i++)
{
int xx=x+dir[i][];
int yy=y+dir[i][];
if(xx>=&&xx<n&&yy>=&&yy<m&&(s[xx][yy]=='*'||b[xx][yy]))
w[x][y]++;
if(xx>=&&xx<n&&yy>=&&yy<m&&s[xx][yy]=='.'&&!b[xx][yy])
{
if(q(xx,yy)==)
w[x][y]++;
}
} if(w[x][y]==)
return ;
return ;
} int main()
{
int T,k=,i,j; scanf("%d", &T); while(T--)
{
memset(w,,sizeof(w)); scanf("%d %d", &n,&m); for(i=; i<n; i++)
scanf("%s", s[i]); printf("Case %d:\n",k++); for(i=; i<n; i++)
{
for(j=; j<m; j++)
{
if(s[i][j]=='.')
{
memset(w,,sizeof(w));
memset(b,,sizeof(b)); if(q(i,j)==)
s[i][j]='*';
} printf("%c", s[i][j]);
}
printf("\n");
}
}
return ;
}

Problem H: 小火山的围棋梦想 多校训练2(小火山专场)的更多相关文章

  1. ZZULIoj 1908 小火山的围棋梦想

    Description   小火山最近喜欢上了围棋.   对于围棋,其实小火山是一窍不通的.现在棋盘上,有很多小火山的棋子. 如果棋盘上有这样的一个位置, 那么这个位置也会变成小火山 的棋子:这样的位 ...

  2. Problem A: 小火山的跳子游戏 多校训练2(小火山专场)(周期)

    题目链接:http://acm.zzuli.edu.cn/zzuliacm/problem.php?cid=1158&pid=0 zzuli 1905  题意:如果k=1的话是1,2,3,4. ...

  3. Problem H: 小姐姐的QQ号(DFS)

    Contest - 河南省多校连萌(四) Problem H: 小姐姐的QQ号 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 297  Solved:  ...

  4. 清北学堂入学测试P4751 H’s problem(h)

    P4751 H’s problem(h)  时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试 描述 小H是一个喜欢逛街的女孩子,但是由于上了大学 ...

  5. HDU 6326.Problem H. Monster Hunter-贪心(优先队列)+流水线排序+路径压缩、节点合并(并查集) (2018 Multi-University Training Contest 3 1008)

    6326.Problem H. Monster Hunter 题意就是打怪兽,给定一棵 n 个点的树,除 1 外每个点有一只怪兽,打败它需要先消耗 ai点 HP,再恢复 bi点 HP.求从 1 号点出 ...

  6. Problem H. Hotel in Ves Lagos

    Problem H. Hotel in Ves Lagos Input le: hotel.in Output le: hotel.out Time limit: 1 second Memory li ...

  7. HDU 6326 Problem H Monster Hunter

    \(\mathtt{Problem H}\) \(\mathtt{Monster}\) \(\mathtt{Hunter}\) \(\mathcal{Description}\) 题目 给定一棵 \( ...

  8. 实验12:Problem H: 整型数组运算符重载

    Home Web Board ProblemSet Standing Status Statistics   Problem H: 整型数组运算符重载 Problem H: 整型数组运算符重载 Tim ...

  9. The Ninth Hunan Collegiate Programming Contest (2013) Problem H

    Problem H High bridge, low bridge Q: There are one high bridge and one low bridge across the river. ...

随机推荐

  1. 可以有效防护XSS,sql注射,代码执行,文件包含等多种高危漏洞。

    http://bbs.aliyun.com/read/137391.html <?php /** * 云体检通用漏洞防护补丁v1.1 * 更新时间:2013-05-25 * 功能说明:防护XSS ...

  2. UIAlertAction 弹出对话框9.0后有点变化

    ios 9.0后再用以前的UIAlertAction 已经不行了 被弃用了 改用这种方法了 UIAlertController *alertController = [UIAlertControlle ...

  3. Activity之间的隐士跳转

    /**             * 方法一:在构造函数中指定             */            /*Intent intent=new Intent(this,TwoActivity ...

  4. C# WebRequest简单调用WebService方法

    //get string res = GetStringByUrl("http://你的地址/WebService.asmx/方法名?参数=1"); //post string r ...

  5. Linux下tomcat的安装详解

    Linux下tomcat的安装详解 来源: ChinaUnix博客 日期: 2007.01.21 22:59 (共有0条评论) 我要评论 一,安装前的准备:1,Linux版本:我的是企业版.(至于红帽 ...

  6. Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLIC

    在mysql5中遇到的问题: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) f ...

  7. tomcat 高并发配置 与优化

    公司的一个服务器使用Tomcat6默认配置,在后台一阵全点击服务器就报废了,查了一下就要是PERMSIZE默认值过小造成(16-64) TOMCAT_HOME/bin/catalina.sh 添加一行 ...

  8. IOS 播放视频 MPMoviePlayerController

    在unity游戏的开头播放视频 , 根据需求 , 最后决定用 MPMoviePlayerController 来实现播放, 实现如下: by Tin 需要在AppController.mm的 Open ...

  9. shell之路【第二篇】运算与文件调用

    Bash 支持很多运算符,包括算数运算符.关系运算符.布尔运算符.字符串运算符和文件测试运算符. 原生bash不支持简单的数学运算,默认都是字符串操作,但是可以通过其他命令来实现 算数运算 expr. ...

  10. PHP之Zip扩展,解压缩文件,ZipArchive类

    <?php $zip = new ZipArchive();//新建一个对象 /* $zip->open这个方法第一个参数表示处理的zip文件名. 第二个参数表示处理模式,ZipArchi ...