POJ-1573 Robot Motion 模拟水题
2012-12-27 00:09
435 查看
题目链接:http://poj.org/problem?id=1573
随便模拟,水水~
随便模拟,水水~
//STATUS:G++_AC_0MS_696KB #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<stack> using namespace std; #define LL __int64 #define pii pair<int,int> #define Max(a,b) ((a)>(b)?(a):(b)) #define Min(a,b) ((a)<(b)?(a):(b)) #define mem(a,b) memset(a,b,sizeof(a)) #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 const int MAX=110,INF=0x3f3f3f3f,MOD=1999997; const LL LLNF=0x3f3f3f3f3f3f3f3fLL; char map[MAX][MAX]; int ma[128],dx[4]={-1,0,1,0},dy[4]={0,1,0,-1}; int n,m,s,ans1,ans2; int dfs(int x,int y,int d) { int t=map[x][y]; if(x<0||x>=n || y<0||y>=m){ ans1=d; return 1; } if(t<'A'){ ans1=t;ans2=d-t; return 0; } map[x][y]=d; dfs(x+dx[ma[t]],y+dy[ma[t]],d+1); } int main() { // freopen("in.txt","r",stdin); int i,j; ma['N']=0,ma['E']=1,ma['S']=2,ma['W']=3; while(~scanf("%d%d%d",&n,&m,&s) && n) { for(i=0;i<n;i++) scanf("%s",map[i]); if(dfs(0,s-1,0))printf("%d step(s) to exit\n",ans1); else printf("%d step(s) before a loop of %d step(s)\n",ans1,ans2); } return 0; }
相关文章推荐
- POJ 1573 Robot Motion (模拟+不回溯的dfs 水题)
- Robot Motion(POJ 1573)(水题+纯模拟)
- POJ 1573 Robot Motion(模拟)
- POJ 1573 Robot Motion 模拟
- POJ 1573 Robot Motion 模拟 难度:0
- POJ 1573 Robot Motion 模拟
- POJ 1573 Robot Motion 水模拟
- HDU 1035 && 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 & 【HDU】1035 - Robot Motion(模拟)
- POJ 1573:Robot Motion:简单模拟
- POJ 1573 Robot Motion(小模拟)
- POJ 1573-Robot Motion(模拟)
- 模拟 POJ 1573 Robot Motion