猴群(normal)
来源:互联网 发布:gartner 中国软件支出 编辑:程序博客网 时间:2024/04/23 17:37
猴群(normal)
Time Limit:1000MS Memory Limit:65536K
Total Submit:101 Accepted:45
Description
输入一个矩阵(n*m),由0~9组成,其中数字0代表树,1~9代表猴子,凡是群居在一起的猴子称之为一群猴子。现在要你找出当中有多少只猴子。
Input
第一行两个整数n,m。(n<=1000;m<=1000)
接下来是一个n*m的矩阵。含义见题目描述。
Output
一个整数,表明有多少群猴子。
Sample Input
4 100234500067103456050020456006710000000089
Sample Output
4
Source
Fstephen
var a:array[-1..10000,-1..10000]of boolean; i,j,n,m,tot:longint;procedure init;var i,j:longint; ch:char; s:string;begin readln(n,m); for i:=1 to n do begin for j:=1 to m do begin read(ch); if ord(ch)>ord('0') then a[i,j]:=true; end; readln; end;end;procedure ppp(x,y:longint);begin a[i,j]:=false;end;procedure pp(x,y:longint);var i,j:longint;begin a[x,y]:=false; if a[x+1,y] then pp(x+1,y); if a[x-1,y] then pp(x-1,y); if a[x,y+1] then pp(x,y+1); if a[x,y-1] then pp(x,y-1);end;begin init; for i:=1 to n do for j:=1 to m do begin if a[i,j] then begin pp(i,j); inc(tot);end; end; writeln(tot);end.
0 0
- 猴群(normal)
- normal
- Normal
- Normal Mapping
- normal form
- normal transform
- Normal Distribute
- Normal Map
- vertex normal
- Normal Mapping
- normal distribution
- normal map
- normal equation
- 删边(normal)
- 删边(normal)
- 删边(normal)
- (ab)normal
- Normal Mapping
- http://www.regexr.com/
- 使用Maven报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Unity 地形高度图生成方法
- 如何将java web项目上线/部署到公网
- lua使用优化建议
- 猴群(normal)
- su 与 su- 的区别
- 导航数据标准NDS结构简介
- 斗地主AI算法——第二章の数据结构
- linux命令之crontab命令使用详解
- 图形图像处理控件ImageGear for .NET v22.2发布,增加新的简化示例
- 在Android上运行C语言编写的可执行程序
- Activity继承自AppCompatActivity隐藏标题栏
- leetcode-523. Continuous Subarray Sum