1751: [Usaco2005 qua]Lake Counting
1751: [Usaco2005 qua]Lake Counting
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 190 Solved: 150
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
W........WW.
.WWW.....WWW
....WW...WW.
.........WW.
.........W..
..W......W..
.W.W.....WW.
W.W.W.....W.
.W.W......W.
..W.......W.
Sample Output
OUTPUT DETAILS:
There are three ponds: one in the upper left, one in the lower left,
and one along the right side.
HINT
Source
题解:直接萌萌哒DFS秒之,经典的普及组难度基础题,水水哒
(Tip:38行的dfs(a1,a2)貌似只有这样写在本机才能对,提交也能A;很神奇的是如果直接写dfs(i,j)的话在本机就会出现带入的是(1,1)结果进去的是(2,2)QAQ,然后各种神奇跪OTL,更神奇的是这个在本机都跪成狗的程序居然submit之后也能A(QAQ),求神犇解释)
var
i,j,k,l,m,n,a1,a2:longint;
c1:char;
a:array[..,..] of longint;
procedure dfs(x,y:longint);inline;
begin
a[x,y]:=;
if a[x-,y-]= then dfs(x-,y-);
if a[x,y-]= then dfs(x,y-);
if a[x+,y-]= then dfs(x+,y-);
if a[x-,y+]= then dfs(x-,y+);
if a[x,y+]= then dfs(x,y+);
if a[x+,y+]= then dfs(x+,y+);
if a[x-,y]= then dfs(x-,y);
if a[x+,y]= then dfs(x+,y);
end;
begin
readln(n,m);
fillchar(a,sizeof(a),);
for i:= to n do
begin
for j:= to m do
begin
read(c1);
case c1 of
'W':a[i,j]:=;
'.':a[i,j]:=;
end;
end;
readln;
end;
l:=;
for i:= to n do
for j:= to m do
if a[i,j]= then
begin
a1:=i;a2:=j;
inc(l);dfs(a1,a2);
end;
writeln(l);
readln;
end.
1751: [Usaco2005 qua]Lake Counting的更多相关文章
- bzoj1751 [Usaco2005 qua]Lake Counting
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec Memory Limit: 64 MB Submit: 168 Solved: 130 [ ...
- POJ_2386 Lake Counting (dfs 错了一个负号找了一上午)
来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS Memory Limit: 65536 ...
- POJ 2386 Lake Counting(深搜)
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17917 Accepted: 906 ...
- POJ 2386 Lake Counting
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28966 Accepted: 14505 D ...
- BZOJ1754: [Usaco2005 qua]Bull Math
1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 374 Solved: 227[Submit ...
- BZOJ2023: [Usaco2005 Nov]Ant Counting 数蚂蚁
2023: [Usaco2005 Nov]Ant Counting 数蚂蚁 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 56 Solved: 16[S ...
- BZOJ 3385: [Usaco2004 Nov]Lake Counting 数池塘
题目 3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec Memory Limit: 128 MB Description 农夫 ...
- 1755: [Usaco2005 qua]Bank Interest
1755: [Usaco2005 qua]Bank Interest Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 187 Solved: 162[Su ...
- 1753: [Usaco2005 qua]Who's in the Middle
1753: [Usaco2005 qua]Who's in the Middle Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 290 Solved: ...
随机推荐
- "类型初始值设定项引发异常"
问题出现的原因:在对类中的字段或属性直接赋值的时候出现异常而造成的这个异常. 例如: class MyClass { public static string ConnectionString = G ...
- jQuery 对象与Dom 对象互转
jQuery 对象与Dom 对象互转: $obj --[i],get(i)-->obj --$(obj)-->$obj; obj--$($(obj))-->$obj,多包装了也是$o ...
- doubango地址配置
转自:http://wiki.sip2sip.info/projects/sip2sip/wiki/SipDeviceConfiguration SIP Device Configuration Th ...
- 30万奖金!还带你奔赴加拿大相约KDD!?阿里聚安全算法挑战赛带你飞起!
KDD(Knowledge Discovery and Data Mining,知识发现与数据挖掘)会议,作为数据挖掘届的顶会,一直是算法爱好者心中的圣地麦加. 想去?有点难. 给你奖金和差旅赞助 ...
- HDU5692(线段树+dfs序)
Snacks Time Limit:5000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- 关于OI本地简易评测姬3.0发布的通知
本辣鸡蒟蒻的OI本地评测姬3.0出炉辣.[由wjc大蒟蒻编写,rxb神犇秒秒钟搞出编译器命令行,解决了评测姬编译一大难关并便携化,也为评测姬设计提出了宝贵的建议],目前支持pas和cpp(本辣鸡错了, ...
- LCD驱动移植在在mini2440(linux2.6.29)和FS4412(linux3.14.78)上实现对比(deep dive)
1.Linux帧缓冲子系统 帧缓冲(FrameBuffer)是Linux为显示设备提供的一个接口,用户可以将帧缓冲看成是显示内存的一种映像,将其映射到进程地址空间之后,就可以直接进行读写操作,而写操作 ...
- autotools归纳
最近接触到许多linux项目,其编译都是使用的autotools. autotools是一个自动化的编译工具.个人理解它的最主要功能就是生成Makefile. 因为直接写Makefiel,其依赖关系还 ...
- DHCP协议
来源摘取自百度百科 DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作, 主要有两个用途:给内部网络或网络服 ...
- Swift 面向对象解析(一)
面向对象总体概括: Swift 不仅能够面向过程编程,也能够面向对象编程(OOP).面向对象其实就是“以对象为核心”,把我们的客观世界想着是由一个个对象组成的,面向对象编程则为对象提供了属性和方法,属 ...