多校 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 ...
随机推荐
- 6.编写一个Java应用程序,该应用程序包括2个类:Print类和主类E。Print 类里有一个方法output()功能是输出100 ~ 999之间的所有水仙花数(各位数字的 立方和等于这个三位数本身,如: 371 = 33 + 73 + 13。)在主类E的main方法中来 测试类Print。
Print类: package com.bao; public class Print { int g,s,b; void outPut() { for(int i=100;i<1000;i++ ...
- UI----安健1 button lable textfiend
//按钮 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect ];//按钮形状 button.frame = CGR ...
- Default Constructor的构造操作
Default Constructor的构造操作 C++ Annotated Reference Manual书中的Section 12.1说过:default constructor 只有在编译器需 ...
- samba配置(基础版)
1. 下载及安装Samba 推荐用yum来安装,这样它可以自己解决包的依赖关系,省时.省事又方便.一条命令搞定: yum -y install samba 2. 配置Samba 关于Samba的配 ...
- 《Windows驱动开发技术详解》之驱动程序的同步处理
中断请求级 中断请求被分为软件中断和硬件中断两种,这些中断都映射成不同级别的中断请求级.每个中断请求都有各自的优先级别,正在运行的线程随时都可以被中断打断,进入到中断处理程序.优先级高的中断来临时,处 ...
- html 任意表格
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> ...
- OpenCV成长之路:图像直方图
http://ronny.blog.51cto.com/8801997/1394115 2014-04-11 13:47:27 标签:opencv 直方图 统计表 原创作品,允许转载,转载时请务必以超 ...
- mvc UrlHelper
何谓Helper,其实就是在View中为了实现一些灵活功能而写的方法组. 其实ASP.NET MVC的View是Aspx的页面,本身可以声明定义方法,那为什么要有Helper呢? 其实无非是将界面与逻 ...
- 安装 nodejs
接下来使用npm命令安装express和socket.io 没有的话 用yum 安装一下 12 npm install --save expressnpm install --save socket. ...
- .net简单的静态页生成
1.得到实体对象model,读取模板 string htmlMaster = File.ReadAllText(HttpContext.Current.Server.MapPath("/ma ...