POJ 1573 Robot Motion 水模拟
来源:互联网 发布:mac怎么移动文件 编辑:程序博客网 时间:2024/06/09 23:24
step后面的s不用讨论,~~~~不然wa.......
#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>#include <cmath>using namespace std;//0,1,2,3,N,W,S,Eint map[15][15];char a[15][15];int dx[] = {-1,0,1,0};int dy[] = {0,-1,0,1};int main(){ int n, m, k; int i, j; while(cin >> n >> m >> k){ memset(map,0,sizeof(map)); memset(a,0,sizeof(a)); if(n==0&&m==0&&k==0) break; for(i = 0;i < n;i++){ cin >> a[i]; } for(i = 1;i <= n;i++){ for(j = 1;j <= m;j++){ if(a[i-1][j-1] == 'N'){ map[i][j] = 0; }else if(a[i-1][j-1] == 'W'){ map[i][j] = 1; }else if(a[i-1][j-1] == 'S'){ map[i][j] = 2; }else if(a[i-1][j-1] == 'E'){ map[i][j] = 3; } } } int x = 1, y = k; int cnt[15][15]; memset(cnt,0,sizeof(cnt)); cnt[x][y] = 1; int xx =1, yy = k; while(1){ x = xx; y = yy; xx = x+dx[map[x][y]]; yy = y+dy[map[x][y]]; if(xx>=1&&xx<=n&&yy>=1&&yy<=m){ if(cnt[xx][yy] == 0){ cnt[xx][yy] = cnt[x][y] + 1; }else { int tt = cnt[x][y] - cnt[xx][yy] +1; printf("%d step(s) before a loop of %d step(s)\n", cnt[xx][yy]-1, tt); break; } }else { printf("%d step(s) to exit\n", cnt[x][y]); break; } } } return 0;}
0 0
- POJ 1573 Robot Motion(模拟水题)
- POJ 1573 Robot Motion 水模拟
- POJ 1573 Robot Motion模拟
- POJ 1573 Robot Motion 模拟
- POJ 1573 Robot Motion 模拟
- POJ 1573 Robot Motion 模拟
- POJ 1573-Robot Motion(模拟)
- poj-1573-Robot Motion--模拟
- POJ 1573 Robot Motion(模拟)
- poj 1573 Robot Motion(模拟)
- poj 1573 Robot Motion 模拟
- POJ 1573 Robot Motion 递归模拟
- poj 1573 Robot Motion(模拟题)
- POJ 1573:Robot Motion:简单模拟
- POJ 1573 Robot Motion (经典模拟)
- POJ 1573 Robot Motion(模拟)
- HDU 1035 && poj 1573 Robot Motion【模拟】
- POJ 1573 Robot Motion 模拟机器人行走
- MySQL表查询优化(一):妙用explain中的type指标
- PE文件是什么?
- 安卓webView实现长按二维码的自动识别功能
- 类声明和定义中的共有和私有类型的一些注意事项。
- UVA12186 Another Crisis dp 题解
- POJ 1573 Robot Motion 水模拟
- 连续弹出的多个Toast长时间显示,不消失。
- DFS hdu1181(变形课)
- SQL语句学习笔记
- Solr配置
- ImageLoder异步加载图片工具包
- Java常用类(String,File)
- 内存日志系统
- HDU 1010 Tempter of the Bone(逃离地狱,DFS,剪枝,错题集)