poj 1573 Robot Motion
2010-07-17 15:45
316 查看
http://acm.pku.edu.cn/JudgeOnline/problem?id=1573
一个简单的模拟题,
写这篇解题报告用于告诫英语跟我一样烂的兄弟姐妹们,
"whether or not the number before it is 1"意为:
无论前面的数字是否为1,step后面都要跟(s), 也就是无论前面的数字是什么, 都是step(s)
为此, 鄙人光荣的贡献了2个WA,囧
也怪自己没仔细去看题目, 想当然的以为当步数小于1时, 应该写成step....
ps: 被难题虐是应该的, 被水题虐得死去活来的是在不应该啊...- -
一个简单的模拟题,
写这篇解题报告用于告诫英语跟我一样烂的兄弟姐妹们,
"whether or not the number before it is 1"意为:
无论前面的数字是否为1,step后面都要跟(s), 也就是无论前面的数字是什么, 都是step(s)
为此, 鄙人光荣的贡献了2个WA,囧
也怪自己没仔细去看题目, 想当然的以为当步数小于1时, 应该写成step....
ps: 被难题虐是应该的, 被水题虐得死去活来的是在不应该啊...- -
#include<iostream> using namespace std; int main() { int row, col, t, i, j, step[10][10], tmp, st, loopst; char c[10][11]; bool visted[10][10], isLoop, isExit; while(scanf("%d%d%d", &row, &col, &t) && (row||col||t)) { memset(visted, 0, sizeof(visted)); for(i=0; i<row; i++) scanf("%s", c[i]); i = 0, j = t-1; visted[i][j] = 1; step[i][j] = 0; isLoop = isExit = false; st = 0; while(1) { st++; tmp = step[i][j]; switch(c[i][j]) { case 'S': i++; break; case 'N': i--; break; case 'E': j++; break; case 'W': j--; break; default: break; } if(i<0 || i>=row || j<0 || j>=col) { isExit = true; break; } else if(visted[i][j]) { isLoop = true; st = step[i][j]; loopst = tmp - step[i][j] + 1; break; } step[i][j] = tmp+1; visted[i][j] = 1; } if(isExit) printf("%d step(s) to exit/n", st); else if(isLoop) printf("%d step(s) before a loop of %d step(s)/n", st, loopst); } return 0; }
相关文章推荐
- POJ 刷题系列:1573. Robot Motion
- POJ 1573 Robot Motion(BFS)
- POJ 1573 Robot Motion 模拟机器人行走
- poj 1573 Robot Motion 模拟
- poj 1573 Robot Motion(模拟题)
- POJ -1573 Robot Motion
- Robot Motion--POJ 1573
- POJ 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 (模拟)
- POJ-1573 Robot Motion 模拟水题
- POJ-1573-Robot Motion
- poj 1573 Robot Motion
- POJ 1573 Robot Motion 水模拟
- poj 1573 Robot Motion
- poj-1573 Robot Motion