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的更多相关文章

  1. 模拟 POJ 1573 Robot Motion

    题目地址:http://poj.org/problem?id=1573 /* 题意:给定地图和起始位置,robot(上下左右)一步一步去走,问走出地图的步数 如果是死循环,输出走进死循环之前的步数和死 ...

  2. POJ 1573 Robot Motion(BFS)

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12856   Accepted: 6240 Des ...

  3. Poj OpenJudge 百练 1573 Robot Motion

    1.Link: http://poj.org/problem?id=1573 http://bailian.openjudge.cn/practice/1573/ 2.Content: Robot M ...

  4. POJ 1573 Robot Motion(模拟)

    题目代号:POJ 1573 题目链接:http://poj.org/problem?id=1573 Language: Default Robot Motion Time Limit: 1000MS ...

  5. Robot Motion 分类: POJ 2015-06-29 13:45 11人阅读 评论(0) 收藏

    Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11262 Accepted: 5482 Descrip ...

  6. POJ 1573 Robot Motion

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12978   Accepted: 6290 Des ...

  7. poj 1573 Robot Motion【模拟题 写个while循环一直到机器人跳出来】

                                                                                                         ...

  8. 【POJ - 1573】Robot Motion

    -->Robot Motion 直接中文 Descriptions: 样例1 样例2 有一个N*M的区域,机器人从第一行的第几列进入,该区域全部由'N' , 'S' , 'W' , 'E' ,走 ...

  9. POJ 1573:Robot Motion

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11324   Accepted: 5512 Des ...

随机推荐

  1. web.xml基本配置描述

    先加载一段写好的web.xml: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2. ...

  2. 技术型创业者easy遇到的三大问题

    关于创业这事儿.由于经历的事情实在是太多了,所以真是想到哪儿写到哪儿. 这一篇算是<杂记>的番外篇.我今天想说的东西太多了,实在是非常想和很多其它人讨论讨论关于创业的事情. 这样的感觉就像 ...

  3. Eclipse导入Gradle时报错:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

    百度查到http://stackoverflow.com/questions/19794200/gradle-android-and-the-android-home-sdk-location 按照其 ...

  4. 阿里云服务器[教程3]一键安装php+mysql+ftp+nginx环境

    直接看地址 http://help.aliyun.com/manual?spm=0.0.0.0.F5PPZs&helpId=129

  5. [Javascript] Advanced Console Log Arguments

    Get more mileage from your console output by going beyond mere string logging - log entire introspec ...

  6. springMVC3学习(二)--ModelAndView对象

    当控制器处理完请求时,一般会将包括视图名称或视图对象以及一些模型属性的ModelAndView对象返回到DispatcherServlet. 因此,常常须要在控制器中构造ModelAndView对象. ...

  7. linux nadianshi

    http://www.cnblogs.com/fnng/archive/2012/03/19/2407162.html

  8. EventBus分析

    1. 功能介绍 1.1 EventBus EventBus 是一个 Android 事件发布/订阅框架,通过解耦发布者和订阅者简化 Android 事件传递,这里的事件可以理解为消息,本文中统一称为事 ...

  9. Python之路,Day23-----暂无正在更新中

    Python之路,Day23-----暂无正在更新中

  10. sql的一些小东西

    1.sa账户密码丢失. 先用wiondows验证登陆,然后新建查询 “ ALTER LOGIN [sa] WITH PASSWORD = N'NewPassword' ”