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: ...
随机推荐
- 把记事本文件固定在Win8的开始屏幕
1.创建该文件的桌面快捷方式: 2.将快捷方式拷贝至开始菜单目录,在开始屏幕的查看全部中可以看见该文件快捷: 3.在查看全部中右键点击该快捷,选择固定在开始屏幕:
- PHP扩展之多线程
PHP一直以为不支持多线程,后面才知道有基于pThread的扩展包,地址如下: http://php.net/manual/zh/book.pthreads.php 我感兴趣的是以下几个点: 1.Th ...
- Spring MVC DispatcherServlet绑定多种URL
需要学习的内容: http://my.oschina.net/shishuifox/blog/215617 当前的处理方式,在web.xml中配置: <servlet> <servl ...
- RIP 相对寻址
知识共享许可协议本作品采用知识共享署名 4.0 国际许可协议进行许可.转载保留声明头部与原文链接https://luzeshu.com/blog/rip-relative-addressing 本博客 ...
- Java连接数据库(mysql,sqlserver)
犹记当年为了使用java程序连接mysql数据库花费一天时间,最后发现是没有导入外包,如今看来真的发现自己那时有点二,也怪我使用的教科书上没有说明这点(强行甩锅,哈哈).今天分享出来,,希望后者不因为 ...
- ABP入门系列(10)——扩展AbpSession
ABP入门系列目录--学习Abp框架之实操演练 源码路径:Github-LearningMpaAbp 一.AbpSession是Session吗? 1.首先来看看它们分别对应的类型是什么? 查看源码发 ...
- “-webkit-font-smoothing”
CSS3里面加入了一个"-webkit-font-smoothing"属性. 这个属性可以使页面上的字体抗锯齿,使用后字体看起来会更清晰舒服. 加上之后就顿时感觉页面小清晰了. 淘 ...
- HUST 1541 Student’s question
1541 - Student’s question 时间限制:1秒 内存限制:128兆 696 次提交 134 次通过 题目描述 YYis a student. He is tired of calc ...
- .Net程序员学用Oracle系列(17):数据库管理工具(SQL Plus)
1.数据库管理工具概述 2.SQL Plus 实用命令参考 2.1.连接/断开命令 2.2.执行 SQL 语句 2.3.执行 PL/SQL 语句 2.4.文件操作命令 2.5.修改用户密码 2.6.执 ...
- Cordova的搭建
Cordova的搭建 cordova也叫phonegap,可以用来打包网页生成Android或iOS或其他平台的APP,它提供了一些native api,可以让网页调用本地函数,极大地增强了网页的功能 ...