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. PHP学习之[第08讲]数据库MySQL基础之增删改查

    一.工具: 1.phpMyAdmin (http://www.phpmyadmin.net/) 2.Navicat (http://www.navicat.com/) 3.MySQL GUI Tool ...

  2. 30余套系统模版|DIV+CSS网页模板|简洁大气系统模板

    30余套系统模版|DIV+CSS网页模板|简洁大气系统模板.都是一些后台系统的模版,很适合开发一些管理系统,办公系统,网站后台系统等.使用很广泛,很实用的系统模版. 下载地址: 点击下载

  3. solr ,hadoop ,lucene,nutch 的关系和区别

    apache lucene是apache下一个著名的开源搜索引擎内核,基于Java技术,处理索引,拼写检查,点击高亮和其他分析,分词等技术. nutch和solr原来都是lucene下的子项目.但后来 ...

  4. 3Dmax导出fbx文件缺失纹理问题

  5. Android ViewPager PagerAdapter 图片轮播

    ViewPager类直接继承了ViewGroup类,所有它是一个容器类,可以在其中添加其他的View类. ViewPager类需要一个PagerAdapter适配器类给它提供数据. ViewPager ...

  6. [PWA] 0. Introduce to Offline First

    Why offline first? Imagin you are visiting a website, it is fine if wifi connection is good. It migh ...

  7. [WebStrom] Change default cmd to Cygwin

    GO to setting, search Terminal: Change shell path : C:\cygwin\bin\bash.exe --login -i    (to the loc ...

  8. jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档

    原文:https://docs.jboss.org/author/display/AS7/Java+API+for+RESTful+Web+Services+(JAX-RS) Content Tuto ...

  9. Eclipse中输入系统变量和运行参数--转

    原文地址:http://chenzhou123520.iteye.com/blog/1931670 在开发时,有时候可能需要根据不同的环境设置不同的系统参数,我们都知道,在使用java -jar命令时 ...

  10. Linux 下Mysql自动备份脚本

    backdb.sh 文件 #!/bin/bash USER="root" PASSWORD="888888" DATABASE="mydb" ...