poj2056 2010.2.20
来源:互联网 发布:夺宝app源码 编辑:程序博客网 时间:2024/06/13 23:49
poj2056 2010.2.20
#include <iostream>#include <cstring>using namespace std;int Grid[202][202];int main(){int m,n;char ch;while(cin>>n>>m,n){ memset(Grid,0,sizeof(Grid)); bool flag = true; int x,y,d,cnt = 0; for(int i=1;i<=n;++i) { for(int j=1;j<=m;++j) { cin>>ch; if(ch == 'S') { if(flag) { flag = false; x = i; y = j; } Grid[i][j] = 1; ++cnt; } } } bool CanDown=false,CanLeft=false,CanRight=false; if(Grid[x+1][y] == 1) { if(x == 1) d = 1; else d = 2; CanDown = true; } else { d = 0; CanRight = true; } do{ if(Grid[x+1][y] == 1 && CanDown) { CanLeft=true; CanRight=true; ++x; } else if(Grid[x][y+1] == 1 && CanRight) { CanLeft = false; CanDown = true; ++y; cnt -= d; d = 0; } else if(Grid[x][y-1] == 1 && CanLeft) { CanRight = false; CanDown = true; --y; d=2; } }while(x != n && y != m); if(x == n && d == 2) { cnt -= 1; } cout<<cnt<<endl;}return 0;}
0 0
- poj2056 2010.2.20
- poj2056
- POJ2056-The Separator in Grid
- poj2488 2010.2.20
- poj1200 2010.2.20
- poj1080 2010.2.20
- 2010.2.10
- 2010.2.22
- 2010.2.23
- 2010.2.24
- 2010.2.25
- 2010.2.26
- 2010.2.23
- 2010.2.1 星期一 晴
- 2010.2.2日記
- 2010.2.5晴
- 2010.2月总结
- poj1011 2010.2.7
- Linux Mint使用Thunderbird必不可少的系统托盘插件
- 【POI2008】【BZOJ1132】Tro
- poj2488 2010.2.20
- cest
- 第一届蓝桥杯C/C++组编程题2 兑换纸币
- poj2056 2010.2.20
- ASP.NET List泛型分页代码
- 107. Binary Tree Level Order Traversal II
- poj1200 2010.2.20
- Python ConfigParser的使用
- 1003. 我要通过!
- ng-init ng-bind
- Error:Gradle version 2.2 is required. Current version is 1.12
- CF Educational Codeforces Round 6 E题 dfs+线段树