多校 Robot Motion
题目链接: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的更多相关文章
- poj1573 Robot Motion
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12507 Accepted: 6070 Des ...
- Robot Motion(imitate)
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11065 Accepted: 5378 Des ...
- 模拟 POJ 1573 Robot Motion
题目地址:http://poj.org/problem?id=1573 /* 题意:给定地图和起始位置,robot(上下左右)一步一步去走,问走出地图的步数 如果是死循环,输出走进死循环之前的步数和死 ...
- POJ 1573 Robot Motion(BFS)
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12856 Accepted: 6240 Des ...
- Robot Motion 分类: POJ 2015-06-29 13:45 11人阅读 评论(0) 收藏
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11262 Accepted: 5482 Descrip ...
- POJ 1573 Robot Motion
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12978 Accepted: 6290 Des ...
- Poj OpenJudge 百练 1573 Robot Motion
1.Link: http://poj.org/problem?id=1573 http://bailian.openjudge.cn/practice/1573/ 2.Content: Robot M ...
- POJ1573——Robot Motion
Robot Motion Description A robot has been programmed to follow the instructions in its path. Instruc ...
- hdoj 1035 Robot Motion
Robot Motion Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
随机推荐
- caffe层解读系列-softmax_loss
转自:http://blog.csdn.net/shuzfan/article/details/51460895 Loss Function softmax_loss的计算包含2步: (1)计算sof ...
- nginx启动,重启,关闭
1.nginx启动: a. /usr/path/sbin/nginx -c [/etc/path/nginx.conf] 中括号中为指定加载的配置文件,不指定则加载默认配置文件 b. ...
- 4. JavaScript 控制语句
1. If...Else 语句 1.1 条件语句if /* 格式: 1. if ... 2. if ... else ... 3. if ... else if .... else 4. switch ...
- iOS 视图控制器生命周期
1.init: 2.viewDidLoad: 3.viewWillAppear: 4.viewDidAppear: 5.viewWillDisappear; 6.viewDidDisappear
- JavaScript Function arguments.callee caller length return
一.Function 函数是对象,函数名是指针. 函数名实际上是一个指向函数对象的指针. 使用不带圆括号的函数名是访问函数指针,并非调用函数. 函数的名字仅仅是一个包含指针的变量而已.即使在不同的环境 ...
- JavaScript 操作符 变量
一.操作符: 一元操作符 递增操作符 递减操作符 分为 前置型(--a ++a) 和 后置型 (a-- a++) 区别如下: var a = 3,b=6; c = --a +b; //c= ...
- js通过keyCode值判断单击键盘上某个键,然后触发指定的事件
当单击按键时触发事件 document.onkeydown = function (e) { e = e || event; if (e.keyC ...
- C语言_基础代码_01
#include<stdio.h> #include<stdlib.h> #define BUFFERSIZE 1024/*允许处理的最长行有1024个字符*/ /*编译环境v ...
- QTP使用小技巧
1.创建action template. 当希望在每一个新建action时都增加一些头部说明,比如作者.创建日期.说明等,用action template 来实现最简单快捷. ...
- c专家编程---优先级规则
对于一些复杂的类型组合,总是搞不明白,今天阅读了“优先级规则”这块,有了进一步的理解,特将规则记在此处,供自己学习查询使用. 优先级规则: A.声明从它的名字开始读取,然后按照优先级顺序依次读取 B. ...