The Binding of Isaac

Time Limit: 2000MS Memory limit: 65536K

题目描述

Ok, now I will introduce this game to you...

Isaac is trapped in a maze which has many common rooms…

Like this…There are 9 common rooms on the map.

And there is only one super-secret room. We can’t see it on the map. The super-secret room always has many special items in it. Isaac wants to find it but he doesn’t know where it is.Bob 

tells him that the super-secret room is located in an empty place which is adjacent to only one common rooms. 

Two rooms are called adjacent only if they share an edge. But there will be many possible places.

Now Isaac wants you to help him to find how many places may be the super-secret room.

输入

Multiple test cases. The first line contains an integer T (T<=3000), indicating the number of test case.

Each test case begins with a line containing two integers N and M (N<=100, M<=100) indicating the number

of rows and columns. N lines follow, “#” represent a common room. “.” represent an empty place.Common rooms 

maybe not connect. Don’t worry, Isaac can teleport.

输出

One line per case. The number of places which may be the super-secret room.

示例输入

2
5 3
..#
.##
##.
.##
##.
1 1
#

示例输出

8
4

来源

 “浪潮杯”山东省第七届ACM大学生程序设计竞赛

题意

题目虽然看起来很长,但是只要读懂它就非常简单啦~
说的是给你一个地图,’.‘代表空地,‘#’代表门,求在地图中某个非‘#’的点所相邻的上下左右总共有一个‘#’的位置有多少个。
我们可以将整个地图保持在一个字符二维数组中,然后在输入的时候向右向下分别偏移一个单位,因为地图外的一周也要检测啦~
然后枚举所有不是‘#’的点便可以了,反正不会超时,最后输出结果~

AC代码:
#include"stdio.h"
#include"string.h"
#include<iostream>
using namespace std;
char a[105][105];
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int c,b;
        cin>>c>>b;
        getchar();
        memset(a,0,sizeof(a));
        for(int i=1; i<=c; i++)
            gets(a[i]+1);
        int s=0;
        for(int i=0; i<=c+1; i++)
            for(int j=0; j<=b+1; j++)
                if(a[i][j]!='#')
                {
                    int d=0;
                    if(i>0&&a[i-1][j]=='#')d++;
                    if(a[i+1][j]=='#')d++;
                    if(j>0&&a[i][j-1]=='#')d++;
                    if(a[i][j+1]=='#')d++;
                    if(d==1)s++;
                }
        printf("%d\n",s);
    }
    return 0;
}  

山东省第七届ACM省赛------The Binding of Isaac的更多相关文章

  1. 山东省第七届ACM省赛------Memory Leak

    Memory Leak Time Limit: 2000MS Memory limit: 131072K 题目描述 Memory Leak is a well-known kind of bug in ...

  2. 山东省第七届ACM省赛------Reversed Words

    Reversed Words Time Limit: 2000MS Memory limit: 131072K 题目描述 Some aliens are learning English. They ...

  3. 山东省第七届ACM省赛------Triple Nim

    Triple Nim Time Limit: 2000MS Memory limit: 65536K 题目描述 Alice and Bob are always playing all kinds o ...

  4. 山东省第七届ACM省赛------Fibonacci

    Fibonacci Time Limit: 2000MS Memory limit: 131072K 题目描述 Fibonacci numbers are well-known as follow: ...

  5. 山东省第七届ACM省赛------Julyed

    Julyed Time Limit: 2000MS Memory limit: 65536K 题目描述 Julyed is preparing for her CET-6. She has N wor ...

  6. 山东省第七届ACM省赛

    ID Title Hint A Julyed 无 B Fibonacci 打表 C Proxy 最短路径 D Swiss-system tournament 归并排序 E The Binding of ...

  7. 山东省第十届ACM省赛参赛后的学期总结

    5.11,5.12两天的济南之旅结束了,我也参加了人生中第一次正式的acm比赛,虽然是以友情队的身份,但是我依旧十分兴奋. 其实一直想写博客来增加自己的能力的,但是一直拖到现在,正赶上老师要求写一份总 ...

  8. Rectangles(第七届ACM省赛原题+最长上升子序列)

    题目链接: http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=1255 描述 Given N (4 <= N <= 100)  rec ...

  9. 山东理工大学第七届ACM校赛-LCM的个数 分类: 比赛 2015-06-26 10:37 18人阅读 评论(0) 收藏

    LCM的个数 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 对于我们来说求两个数的LCM(最小公倍数)是很容易的事,现在我遇到了 ...

随机推荐

  1. ECMAScript Web APIs node.js

    https://hacks.mozilla.org/2015/04/es6-in-depth-an-introduction/ What falls under the scope of ECMASc ...

  2. 自定义组件-支持PNG图片的多态GraphicButton

    按钮功能使用TButton也可以解决, 但是TButton是会获得焦点的, 很多时候我们要求按钮不获得焦点, 而Speedbutton又不支持PNG图片 所以按照TSpeedbutton的代码, 重新 ...

  3. WebApi接口传参不再困惑(4):传参详解(转载)

    WebApi接口传参不再困惑(4):传参详解   前言:还记得刚使用WebApi那会儿,被它的传参机制折腾了好久,查阅了半天资料.如今,使用WebApi也有段时间了,今天就记录下API接口传参的一些方 ...

  4. java中字节流与字符流的区别

    字节流 在I/O类库中,java.io.InputStream和java.io.OutputStream分别表示字节输入流和字节输出流,它们都是抽象类,不能实例化,数据流中的最小单位是字节,所以叫做字 ...

  5. WordPress忘记登录密码

    后台的登录密码使用的是md5加密的,有时候会忘记登录密码,那么可以修改数据库,把密码改为你知道的字符串的md5加密值 如 hello对应的md5加密值为:5d41402abc4b2a76b9719d9 ...

  6. SSR———团队作业:小型论坛的设计与初步实现

    小型论坛的设计与初步实现 这次团队作业,我们设计的是一个小型论坛,作为团队中的一员,我主要负责对用户进行需求调研与对用户体验的过程拍摄总结,力求我们的项目在力所能及的范围内更加完美 视频:   度盘链 ...

  7. MyEclipse 及Tomcate 安装 配置

    使用的工具为myeclipse-pro-2014-GA-offline-installer-windows(需安装).apache-tomcat-6.0.37.jdk1.6.0.14. 1.MyEcl ...

  8. AOP programming paradiag

    AOP https://en.wikipedia.org/wiki/Aspect-oriented_programming Typically, an aspect is scattered or t ...

  9. Transaction Save Point (SET XACT_ABORT { ON | OFF })

    ref:http://blog.csdn.net/wym3587/article/details/6940630 ref:http://www.cnblogs.com/jiajiayuan/archi ...

  10. rhel 7.0, windows10双系统grub2设置

    因为在win10基础上装了rhel7,但是启动时却没有win10的启动项,下面的方法解决此问题. $ su #root登录 $ cd /boot/grub2 1. 简单执行grub2-mkconfig ...