题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12868&courseid=272

解题报告:输入n*m的地图,+表示土地,-表示水,要你求这个海岛的海岸线有多长,扫一遍就可以了。

 #include<cstdio>
const int maxn = ;
char map[maxn][maxn];
int _x[] = {-,,,};
int _y[] = {,,,-}; int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i = ;i < n;++i)
scanf("%s",map[i]);
int tot = ;
for(int i = ;i < n;++i)
for(int j = ;j < m;++j)
if(map[i][j] == '+')
{
int flag = ;
for(int k = ;k < ;++k)
{
int xx = i + _x[k];
int yy = j + _y[k];
if(xx >= && xx < n && yy >= && yy < m)
if(map[xx][yy] == '-' || map[xx][yy] == '?')
{
flag = ;
break;
}
}
if(flag == ) tot++;
}
printf("%d\n",tot);
}
return ;
}

HNU 12868 Island (简单题)的更多相关文章

  1. BZOJ 2683: 简单题

    2683: 简单题 Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 913  Solved: 379[Submit][Status][Discuss] ...

  2. 【BZOJ-1176&2683】Mokia&简单题 CDQ分治

    1176: [Balkan2007]Mokia Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 1854  Solved: 821[Submit][St ...

  3. Bzoj4066 简单题

    Time Limit: 50 Sec  Memory Limit: 20 MBSubmit: 2185  Solved: 581 Description 你有一个N*N的棋盘,每个格子内有一个整数,初 ...

  4. Bzoj2683 简单题

    Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 1071  Solved: 428 Description 你有一个N*N的棋盘,每个格子内有一个整数, ...

  5. 这样leetcode简单题都更完了

    这样leetcode简单题都更完了,作为水题王的我开始要更新leetcode中等题和难题了,有些挖了很久的坑也将在在这个阶段一一揭晓,接下来的算法性更强,我就要开始分专题更新题目,而不是再以我的A题顺 ...

  6. [BZOJ2683][BZOJ4066]简单题

    [BZOJ2683][BZOJ4066]简单题 试题描述 你有一个N*N的棋盘,每个格子内有一个整数,初始时的时候全部为0,现在需要维护两种操作: 命令 参数限制 内容 1 x y A 1<=x ...

  7. HDU 1753 大明A+B(字符串模拟,简单题)

    简单题,但要考虑一些细节: 前导0不要,后导0不要,小数长度不一样时,有进位时,逆置处理输出 然后处理起来就比较麻烦了. 题目链接 我的代码纯模拟,把小数点前后分开来处理,写的很繁杂,纯当纪念——可怜 ...

  8. 团体程序设计天梯赛-练习集L1-014. 简单题

    L1-014. 简单题 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 这次真的没骗你 —— 这道超级简单的题目没有任何输入. ...

  9. bzoj 4066: 简单题 kd-tree

    4066: 简单题 Time Limit: 50 Sec  Memory Limit: 20 MBSubmit: 234  Solved: 82[Submit][Status][Discuss] De ...

随机推荐

  1. JavaScript DES 加密tripledes.js:

    <html> <head> <meta http-equiv="content-type" content="text/html; char ...

  2. R in bioinformatic

    TCGA https://www.bioconductor.org/packages/release/bioc/vignettes/TCGAbiolinks/inst/doc/tcgaBiolinks ...

  3. CookContainer 序列化保存

    using System;using System.Collections;using System.Globalization;using System.IO;using System.Net;us ...

  4. Ajax异步刷新,测试用户名是否被注册

    <body> <form name="form_register"> <input type="> <input type=&q ...

  5. 兼容IE的写法收集||bug修复

    这篇文章实时更新 属于IE的专属写法 其中,S表示Standards Mode即标准模式,Q表示Quirks Mode,即兼容模式 hack 示例 IE6(S) IE6(Q) IE7(S) IE7(Q ...

  6. js日历插件 中文、英文日历

    日历插件 来源网站:http://www.cnblogs.com/yank/archive/2008/08/14/1267746.html 六款英文日历 http://www.bobd.cn/desi ...

  7. macbook 放flash发烫,转html5

    http://zythum.sinaapp.com/youkuhtml5playerbookmark/

  8. 关于MarshalByRefObject的解释

    http://www.cnblogs.com/webfpc/archive/2010/03/10/1667101.html 首先了解一下不同应用程序域中的对象的通信方式有两种: 一种是跨应用程序域边界 ...

  9. python中单引号,双引号,多引号区别

    先说1双引号与3个双引号的区别,双引号所表示的字符串通常要写成一行如:s1 = "hello,world"如果要写成多行,那么就要使用\ (“连行符”)吧,如s2 = " ...

  10. Drupal 7.31SQL注入getshell漏洞利用详解及EXP

    0x00 这个漏洞威力确实很大,而且Drupal用的也比较多,使用Fuzzing跑字典应该可以扫出很多漏洞主机,但是做批量可能会对对方网站造成很大的损失,所以我也就只是写个Exp不再深入下去. 0x0 ...