寻找向左凸的地方,每个左凸能让S数量-2。上边或下边如果是半个左凸的话则各对应-1

#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std; #define MAX_ROW 205
#define MAX_COLUMN MAX_ROW int row, column;
char grid[MAX_ROW][MAX_COLUMN]; void input()
{
memset(grid, , sizeof(grid));
for (int i = ; i < row; i++)
scanf("%s", grid[i]);
} void work()
{
int direction = -; //1 is right, 0 is left
int s_cnt = ;
int x = ;
int y = ;
while (grid[x][y] != 'S')
y++;
s_cnt++;
while (x < row)
{
if (y != && grid[x][y - ] == 'S')
{
direction = ;
while (y > && grid[x][y - ] == 'S')
y--, s_cnt++;
x++, s_cnt++;
continue;
}
if (y + < column && grid[x][y + ] == 'S')
{
if (direction == -)
s_cnt--;
if (direction == )
s_cnt -= ;
direction = ;
while (y + < column && grid[x][y + ] == 'S')
y++, s_cnt++;
x++, s_cnt++;
continue;
}
x++, s_cnt++;
}
if (direction == )
s_cnt--;
printf("%d\n", s_cnt - );
} int main()
{
while (scanf("%d%d", &row, &column), row | column)
{
input();
work();
}
return ;
}

poj2056的更多相关文章

随机推荐

  1. [转帖学习]Oracle的 SYS_CONTEXT 函数简介

    Oracle的 SYS_CONTEXT 函数简介 https://blog.csdn.net/IndexMan/article/details/48606369 1.什么是SYS_CONTEXT? S ...

  2. dos批量导入不受信任的证书及软件限制策略的应用

    certmgr.exe -add "证书.cer" -s -r localMachine Disallowed 导入授信机构 certmgr -add "证书.cer&q ...

  3. Linux系统编程手册-源码的使用

    转自:http://www.cnblogs.com/pluse/p/6296992.html 第三章后续部分重点介绍了后面章节所要使用的头文件及其实现,主要如下: ename.c.inc error_ ...

  4. 解决sublime text3下中文无法输入的问题(Ubuntu)

    sublime-text-imfix,非常无脑.就喜欢这样的.

  5. Ubuntu 14.04 将一个sh文件制作成类似于windows下的可以双击执行的快捷方式

    # 创建文件 touch test.desktop # 在test.desktop中写入如下内容 [Desktop Entry] Version=1.0 Type=Application Termin ...

  6. Luogu4768 NOI2018归程(最短路径+kruskal重构树)

    按海拔从大到小合并建出kruskal重构树,这样就能知道开车能到达哪些点,对这些点到1的最短路取min即可.最难的部分在于多组数据的初始化和数组大小的设置. #include<iostream& ...

  7. learning hive学习笔记

    http://note.youdao.com/noteshare?id=58f314d67b3a04caac36221a9a046a13

  8. 让外部网络访问K8S service的四种方式

    本文基于kubernetes 1.5.2版本编写 kube-proxy+ClusterIP kubernetes版本大于或者等于1.2时,配置: 修改master的/etc/kubernetes/pr ...

  9. 微信小程序-点击图片预览

    拿接口  有封装 封装查看另外的博文 点击动作 WXHTML 注意 data-xxxx自定义属性 这样知道我点的是哪个参数

  10. 关于Html class id 命名规范

    CSS命名规则 头:header 内容:content/containe 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrapper 左右中:l ...