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. HDU1700:Points on Cycle

    Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...

  2. 关于这两天研究Java打印pdf方法的记录

    这两天在研究Java调用打印机打印PDF文件的方法,学到了不少东西,特别来记录一下. 关于Java打印网上最多的而且也是Java正统的打印方法就是使用PrintService,一套比較标准的打印代码例 ...

  3. 小胖学PHP总结1-----PHP的数据类型

    PHP一共支持8种原始类型.包含4中标量类型,即:boolean(布尔型).integer(整形).float/double(浮点型)和string(字符串型):两种复合类型,即:array(数组)和 ...

  4. VIPServer VS LVS

    http://www.cnblogs.com/nanyangzp/p/5552725.html

  5. 使用APICloud设计物联网APP

    0.前言 1).APP功能: 1.控制室内插座的开关. 2.查看室内实时温湿度和温湿度趋势. 3.控制小车的行走,小车摄像头的开启/关闭.移动. 4.查看摄像头监控画面,可拍照并追溯. 5.查看服务器 ...

  6. js关于闭包的内存的问题--deep down

    js有一个东西叫做GC(garbage collection )垃圾回收机制;js中有两种类型:js基本数据类型,js引用类型; 当一个函数[对象]--引用类型被引用后,过后,出了它的功能之后,gc会 ...

  7. Linq101-Partitioning

    using System; using System.Linq; namespace Linq101 { class Partitioning { /// <summary> /// Th ...

  8. c# 用正则表达式获取开始和结束字符串中间的值

    c# 用正则表达式获取开始和结束字符串中间的值 /// <summary> /// 获得字符串中开始和结束字符串中间得值 /// </summary> /// <para ...

  9. hdu1102 Constructing Roads (简单最小生成树Prim算法)

    Problem Description There are N villages, which are numbered from 1 to N, and you should build some ...

  10. macbook Android开发环境搭建,真机调试

    买了一台MacBook,本以为可以鼓捣一下iOS开发之类的,可惜导师要我做Android开发.无奈开始了在MacBook上开发Android的工作. 从开始配置环境到应用成功在真机上运行,也是曲曲折折 ...