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. Mybatis-Generator 详解 http://www.cnblogs.com/jtzfeng/p/5254798.html

    Mybatis-Generator 自动生成Dao.Model.Mapping相关文档 最近在学习mybatis,结果在写Mapping的映射文件时insert语句一直报错,于是想看看标准的映射文件是 ...

  2. POJ 2418 ,ZOJ 1899 Hardwood Species - from lanshui_Yang

    Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or nu ...

  3. python 参议院文本预处理的一维数组的间隔空间

    #!/usr/bin/python import re def pre_process_msg ( msgIn ):     if msgIn=="":         retur ...

  4. iOS-获取UIView的全部层级结构

    在iOS中获取UIView的全部层级结构 应用场景 在实际 iOS 开发中,非常多时候都须要知道某个 UI 控件中包括哪些子控件,而且分清楚它们的层级结构和自个的 frame 以及 bounds ,以 ...

  5. 【待解决】编译V8引擎出错-snapshot.cc

    这几天学习nodejs,翻阅官网的API文档.看到nodejs插件时,想了解一下v8的实现机制,于是我便从GitHub社区克隆了一份v8源码库.哪知道,编译安装的时候就出了问题,这问题已经折磨我两天了 ...

  6. [转] 使用CodeViz生成C/C++函数调用关系图

    运行环境:虚拟机下的Ubuntu 11.04 结合Graphviz工具,使用CodeViz可以生成直观和漂亮的C/C++程序函数之间的调用关系图. 1.安装graphviz 在安装CodeViz之前, ...

  7. POJ 2049 Finding Nemo

    Finding Nemo Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 8631   Accepted: 2019 Desc ...

  8. Linux FTP YUM源搭建简单记录

    1. 挂载iso镜像,进入Packages目录下安装FTP服务 #rpm -ivh vsftpd-3.0.2-10.el7.x86_64.rpm 2. 修改vsftpd配置文件如下 [root@rus ...

  9. 突然想写点东西,关于web新人的。采用问答方式

    我自己是会计专业,转行自学web的,学习有一两年了,也还是新人一个,只不过不是那种超级“新”的,所以有什么话说得不对,请轻喷.欢迎大家来和我交流. 1.我能不能转行学web? 能不能学web这个不是别 ...

  10. IIS 服务器 支持.apk文件的下载

    IIS服务器不能下载.apk文件的解决办法:既然.apk无法下载是因为没有MIME,那么添加一个MIME类型就可以了 随着智能手机的普及,越来越多的人使用手机上网,很多网站也应手机上网的需要推出了网站 ...