题目链接: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. javamail邮件发送

    // 发送邮件 public static void send(String toEmail, String content) { Session session = getSession(); tr ...

  2. weblogic一些基本概念

    <收藏过来的----------http://www.cnblogs.com/cocowool/archive/2012/04/01/2428861.html> WebLogic中的一些基 ...

  3. D - 娜娜梦游仙境系列——村民的怪癖

    D - 娜娜梦游仙境系列——村民的怪癖 Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Othe ...

  4. NOTE07152246 JAVA 发展及JDK配置

    一.软件工程师体系: 操作系统(Windows/Linux/Unix) - 数据库系统 - 中间件(WebSphere/Tomcat) - JAVA EE 1.操作系统为用户构建了一个平台.此平台上可 ...

  5. cocos2d-x 混合模式

    在OpenGL(ES),使用glBlendFunc函数实现实现混合模式,cocos2d-x中可以使用BlendFunc. 什么是颜色混合?简单来说就是将RGBA中的A,经行操作处理.具体一点,就是把某 ...

  6. 关于LCD的分屏与切屏 Tearing effect

    详细文档(带图片):http://download.csdn.net/detail/xuehui869/5268852 1.LCM之Fmark功能 http://blog.csdn.net/zhand ...

  7. Linux下安装MySQL-5.7

    写在前面:此博客是针对MySQL5.7安装教程,其他版本可能略有不同,仅供参考. 第一步:下载mysql 在Linux终端使用wget命令下载网络资源: wget http://mirrors.soh ...

  8. 在TextView上显示图片信息

    布局文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t ...

  9. LeetCode OJ 236. Lowest Common Ancestor of a Binary Tree

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  10. ACboy needs your help again!

    ACboy needs your help again! Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Ja ...