POJ 1573 Robot Motion
2012-11-14 09:52
423 查看
水模拟题一只。。。
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; int cnt[1000][1000],n,m,lc,s; char map[1000][1000]; int go(int x,int y) { while (1) { if (x < 0 || y < 0 || x >= n || y >= m) { printf("%d step(s) to exit\n",lc-1); break; } if (cnt[x][y] != 0) { printf("%d step(s) before a loop of %d step(s)\n",cnt[x][y]-1,lc-cnt[x][y]); break; } cnt[x][y]=lc; lc++; switch (map[x][y]) { case 'N': x--; break; case 'S': x++; break; case 'E': y++; break; case 'W': y--; break; } } } int main() { int i,j,k; while (1) { scanf("%d%d%d",&n,&m,&s); getchar(); if (n == 0 && m == 0 && s == 0) { break; } s--; memset(cnt,0,sizeof(cnt)); for (i=0; i<n; i++) { gets(map[i]); } lc=1; go(0,s); } }
相关文章推荐
- 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 OpenJudge 百练 1573 Robot Motion
- POJ 1573 && hdu 1035 Robot Motion【简单模拟】
- poj 1573 Robot Motion
- POJ-1573 Robot Motion 模拟水题
- poj 1573 Robot Motion
- poj 1573 Robot Motion
- POJ 1573 Robot Motion (DFS)
- POJ 1573 Robot Motion
- POJ训练计划1573_Robot Motion(递归)
- POJ 1573 Robot Motion
- POJ 1573 Robot Motion 模拟机器人行走
- POJ 1573 && hdu 1035 Robot Motion(简单模拟)