poj 1573Robot Motion
http://poj.org/problem?id=1573
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 500
using namespace std;
char g[maxn][maxn];
int r,l,st;
int vis[maxn][maxn];
int main()
{
while(scanf("%d%d%d",&r,&l,&st)!=EOF)
{
if(r==&&l==&&st==) break;
for(int i=; i<r; i++)
{
scanf("%s",g[i]);
}
int si=,sj=st-;
int step=,step1;
bool flag=false;
memset(vis,,sizeof(vis));
while()
{
if(vis[si][sj])
{
flag=true;
step1=step-vis[si][sj];
break;
}
if((g[si][sj]=='W'&&sj==)||(g[si][sj]=='E'&&sj==l-)||(g[si][sj]=='S'&&si==r-)||(g[si][sj]=='N'&&si==)) break;
vis[si][sj]=step;
if(g[si][sj]=='W')
{
sj--;
}
else if(g[si][sj]=='E')
{
sj++;
}
else if(g[si][sj]=='S')
{
si++;
}
else if(g[si][sj]=='N')
{
si--;
}
step++;
}
if(flag)
{
//printf("%d %d\n",si,sj);
printf("%d step(s) before a loop of %d step(s)\n",vis[si][sj]-,step1);
}
else
printf("%d step(s) to exit\n",step);
}
return ;
}
poj 1573Robot Motion的更多相关文章
- 模拟 POJ 1573 Robot Motion
题目地址:http://poj.org/problem?id=1573 /* 题意:给定地图和起始位置,robot(上下左右)一步一步去走,问走出地图的步数 如果是死循环,输出走进死循环之前的步数和死 ...
- POJ 1573 Robot Motion(BFS)
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12856 Accepted: 6240 Des ...
- Poj OpenJudge 百练 1573 Robot Motion
1.Link: http://poj.org/problem?id=1573 http://bailian.openjudge.cn/practice/1573/ 2.Content: Robot M ...
- POJ 1573 Robot Motion(模拟)
题目代号:POJ 1573 题目链接:http://poj.org/problem?id=1573 Language: Default Robot Motion Time Limit: 1000MS ...
- Robot Motion 分类: POJ 2015-06-29 13:45 11人阅读 评论(0) 收藏
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11262 Accepted: 5482 Descrip ...
- POJ 1573 Robot Motion
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12978 Accepted: 6290 Des ...
- poj 1573 Robot Motion【模拟题 写个while循环一直到机器人跳出来】
...
- 【POJ - 1573】Robot Motion
-->Robot Motion 直接中文 Descriptions: 样例1 样例2 有一个N*M的区域,机器人从第一行的第几列进入,该区域全部由'N' , 'S' , 'W' , 'E' ,走 ...
- POJ 1573:Robot Motion
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11324 Accepted: 5512 Des ...
随机推荐
- [置顶] 步步辨析JS中的对象成员
前提 首先我们应该明白创建一个JS对象的具体实例是实例化的过程,而实例化是通过new关键字实现的,这个对象是含有constructor的,一般的核心对象都会具有constructor以便创建其实例.因 ...
- 黑马程序猿_Java 代理机制学习总结
-------<a href="http://www.itheima.com/"">android培训</a>.<a href=" ...
- Linux Epoll介绍和程序实例
Linux Epoll介绍和程序实例 1. Epoll是何方神圣? Epoll但是当前在Linux下开发大规模并发网络程序的热门人选,Epoll 在Linux2.6内核中正式引入,和select类似, ...
- javaScript的使用
<script>XXX</ccript>HTML文件插入js的主要方法.这个标签主要有以下的几个属性: 1,charset:可选.表示通过src属性指定的字符集. 2,defe ...
- DateGridew导出Excel表+常见错误提示
在敲机房收费系统的时候,显示数据的时候需要将DateGridew 中的数据导出进Excel表.DateGridew导出Excel表是比较常见的,当然导出Excel表有很多种方法,下面是个人认为比较容易 ...
- [Flux] Stores
Store, in Flux which manager the state of the application. You can use EventEmiiter to listen to the ...
- Android开发艺术探索》读书笔记 (8) 第8章 理解Window和WindowManager
第8章 理解Window和WindowManager 8.1 Window和WindowManager (1)Window是抽象类,具体实现是PhoneWindow,通过WindowManager就可 ...
- Verilog之event的用法
编写verilog的testbench时,可使用event变量触发事件. event变量声明为: event var; event触发为: ->var; 捕获触发为: @(var); 在mode ...
- python练习程序_员工信息表_基本实例
python实现增删改查操作员工信息文件,可进行模糊查询: http://edu.51cto.com/lesson/id-13276.html http://edu.51cto.com/lesson/ ...
- ButterKnife 注解
简介 官网:http://jakewharton.github.io/butterknife/ github:https://github.com/JakeWharton/butterknife 依赖 ...