山东省第七届ACM省赛------The Binding of Isaac
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
来源
题意
#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; }
最新文章
- VPN连接常见错误汇总
- cocopod 中添加第三方框架,包含静态库文件,使用svn添加上传
- 如何设置phpMyAdmin自动登录和取消自动登录
- Javascript刷新页面大全
- asp.net MVC 如何隐藏 Response Header 版本号
- java synchronized关键字浅探
- DMG提取安装文件
- spring mvc使用ClassPathXmlApplicationContext或FileSystemXmlApplicationContext和XmlWebApplicationContext类的操作其中 XmlWebApplicationContext是专为Web工程定制的。
- activity-alias的使用
- c++中多态性、dynamic_cast、父类指针、父类对象、子类指针、子类对象
- python︱模块加载(pip安装)以及pycharm安装与报错解决方式
- js文本框字符数输入限制
- margin-top塌陷
- [LSGDOJ1822]书架 Splay
- 【转载】tomcat+nginx+redis实现均衡负载、session共享(二)
- 【转载】linux top命令查看内存及多核CPU的使用讲述
- JAVA设计模式一策略模式(Strategy Pattern)
- javaScript——原型继承四步曲
- <;转载>;http头 http://www.cnblogs.com/meil/archive/2007/03/06/665843.html
- docker-compose初试及命令基础