第七届 山东省ACM The Binding of Isaac(搜索OR暴力。。)
来源:互联网 发布:ios开发书籍推荐知乎 编辑:程序博客网 时间:2024/06/16 10:08
The Binding of Isaac
Problem Description
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.
Input
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.
Output
One line per case. The number of places which may be the super-secret room.
Example Input
25 3..#.####..####.1 1#
Example Output
84
Hint
Author
题意:给你一个地图,判断super-secret room 的数量,规定超秘房间的四周只有一个common room.
直接暴力搜索就好了,没含量,不过注意输入输出的小细节!!!
#include <bits/stdc++.h>using namespace std;#define MAX 110char mmap[MAX][MAX];int dirX[]= {-1,1,0,0};int dirY[]= {0,0,-1,1};int main(){ int T,n,m,sum; char ch[MAX]; scanf("%d",&T); while(T--) { sum=0; scanf("%d%d",&m,&n); for(int i=0; i<m+2; i++) ///整张图初始化 for(int j=0; j<n+2; j++) mmap[i][j]='.';/* getchar(); ///用输入字符的方式 for(int i=1; i<=m; i++){ for(int j=1;j<=n;j++) scanf("%c",&mmap[i][j]); getchar(); }*/ for(int i=1; i<=m; i++) scanf("%s",mmap[i]+1); for(int i=0;i<m+2;i++) ///注意最后的\0 mmap[i][n+1]='.'; for(int i=0; i<m+2; i++) for(int j=0; j<n+2; j++) if(mmap[i][j] == '.') { int tmp=0; for(int k=0; k<4; k++) ///判断四个方向 if( (i+dirX[k]>=0&&i+dirX[k]<=m+1) && (j+dirY[k]>=0&&j+dirY[k]<=n+1) && mmap[i+dirX[k]][j+dirY[k]]=='#') tmp++; if(tmp==1) } printf("%d\n",sum); } return 0;}
- Sublime Text 3 全程详细图文原创教程
- 二十二、UI-Grid 固定
- easyUI 展开DataGrid里面的行显示详细信息
- mysql单表查询语句
- VS2010-MFC:MFC PictureControl控件上自适应显示图片,分图片失真或者图片不失真两种
- 第七届 山东省ACM The Binding of Isaac(搜索OR暴力。。)
- Spring Boot读取自定义properties文件
- 配置服务器 —— 安装Mysql
- jsp实验1.基本使用
- 代码范例-进制转换[数组]
- Emgu学习笔记(四)---Canny、线检测、圆检测
- 【BZOJ】1085 [SCOI2005]骑士精神 IDA*
- linux下修改主机名
- 技术积累20170415(1)