题目链接: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. Developing a Custom Membership Provider from the scratch, and using it in the FBA (Form Based Authentication) in SharePoint 2010

    //http://blog.sharedove.com/adisjugo/index.php/2011/01/05/writing-a-custom-membership-provider-and-u ...

  2. spring框架--IOC容器,依赖注入

    思考: 1. 对象创建创建能否写死? 2. 对象创建细节 对象数量 action  多个   [维护成员变量] service 一个   [不需要维护公共变量] dao     一个   [不需要维护 ...

  3. C#生成word

    using Microsoft.Office.Interop.Word; using System; using System.Collections.Generic; using System.Co ...

  4. JSP 之国际化

    导入 <%@ taglib url="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 创建三个语 ...

  5. ADT(abstract data types)抽象数据类型

    1.What is it? An abstract data type is a set of objects together with a set of operations. 抽象数据类型是带有 ...

  6. SQL SERVER与C#的数据类型对应表

    序号 类别 SQLServer C Sharp 备注 1 整数 bit Boolean True转换为1False转换为0 2 tinyint Byte C Sharp 数据类型都位于System命名 ...

  7. 给php代码添加规范的注释phpDocumentor

    给php代码添加规范的注释更多参考 http://phpdoc.org/docs/latest/index.html在phpdocumentor中,注释分为文档性注释和非文档性注释.所谓文档性注释,是 ...

  8. PHP上传文件详解

    1.上传文件使用的提交方式和请求Content-type POST提交方式,原始的form表单提交请加上enctype="multipart/form-data" 2.MAX_FI ...

  9. MySQL的索引创建、删除

    1_1.添加PRIMARY KEY(主键索引)  mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 1_2.添加UNIQUE ...

  10. 得到root,并且获取密码

    第一次使用ubuntu的时候 先使用这个命令 sudo passwd root 然后就可以改密码了