题目链接:http://acm.hust.edu.cn/vjudge/contest/124435#problem/J

密码:acm





Sample Input

NEESWE
WWWESS
SNWWWW SESWE
EESNW
NWEEN
EWSEN Sample Output
step(s) to exit
step(s) before a loop of step(s)

分析:

 #include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include<queue>
#include<math.h>
using namespace std; #define N 1001
char s[N][N];
int a[N][N],b[N][N]; int main()
{
int n,m,c,ans;
while(scanf("%d%d%d",&n,&m,&c),n+m+c)
{
memset(a,,sizeof(a));
memset(b,,sizeof(b));
ans=; for(int i=;i<=n;i++)
scanf("%s",s[i]); int i=;
int j=c-;///字符串里面从零开始记录的,老是忘~~~~(>_<)~~~~
while(1)
{
b[i][j]=;
if(s[i][j]=='N')
i=i-;
else if(s[i][j]=='S')
i=i+;
else if(s[i][j]=='E')
j=j+;
else
j=j-;
ans++;
if(b[i][j])
{
printf("%d step(s) before a loop of %d step(s)\n",a[i][j],ans-a[i][j]);
break;
}
a[i][j]=ans; if(i==||j==-||i==n+||j==m)
{
printf("%d step(s) to exit\n",ans);
break;
}
}
}
return ;
}

多校 Robot Motion的更多相关文章

  1. poj1573 Robot Motion

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12507   Accepted: 6070 Des ...

  2. Robot Motion(imitate)

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11065   Accepted: 5378 Des ...

  3. 模拟 POJ 1573 Robot Motion

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

  4. POJ 1573 Robot Motion(BFS)

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

  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 OpenJudge 百练 1573 Robot Motion

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

  8. POJ1573——Robot Motion

    Robot Motion Description A robot has been programmed to follow the instructions in its path. Instruc ...

  9. hdoj 1035 Robot Motion

    Robot Motion Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

随机推荐

  1. 1.建立exception包,编写TestException.java程序,主方法中有以下代码,确定其中可能出现的异常,进行捕获处理。

    package d0923; public class TestException { public static void main(String[] args) { for(int i=0;i&l ...

  2. Centos7 设置DNS 服务器

    在CentOS 7下,手工设置 /etc/resolv.conf 里的DNS,过了一会,发现被系统重新覆盖或者清除了.和CentOS 6下的设置DNS方法不同,有几种方式: 1.使用全新的命令行工具 ...

  3. 背包问题matlab程序

    clearclca=0.95k=[5;10;13;4;3;11;13;10;8;16;7;4];k=-k;d=[2;5;18;3;2;5;10;4;11;7;14;6];restriction=46; ...

  4. Linux内核协议栈 NAT性能优化之FAST NAT

    各位看官非常对不起,本文是用因为写的,如果多有不便敬请见谅 代码是在商业公司编写的,在商业产品中也不能开源,再次抱歉   This presentation will highlight our ef ...

  5. Struts2--课程笔记3

    获取ServletAPI: 第一种方式: //在request域中放入属性req,暂且认为getContext()获取的是request域空间,但实际不是        ActionContext.g ...

  6. 详细理解servlet实现的几种方式和生命周期

    现在很多的开发都是用的框架,然后很多同学学习的时候又是直接接触的框架,对于底层的一些开发,完全没有任何的了解.虽然对于业务上面来说,没有什么问题.但是很多时候当你被面试问到,或者是想要了解框架底层原理 ...

  7. PAXOS may not terminate

    It’s easy to see that Paxos does have a failure mode. When two proposers are active at the same time ...

  8. Golang:测试map是否存在

    请看这个url:http://www.du52.com/text.php?id=561 if v, ok := m1["a"]; ok { fmt.Println(v) } els ...

  9. ios导航栏适配

    我们做屏幕导航栏横竖屏适配的时候,会发现top的值多少都有一点的偏移,加了背景色之后从0开始,不加背景色从64开始,解决方法self.extendedLayoutIncludesOpaqueBars ...

  10. PHP扩展开发-简单类扩展

    今天来学习简单类扩展开发 实现目标为如下php的类 <?php class classext(){ private $username; CONST URL="http://www.g ...