zoj1824
2013-04-10 20:34
375 查看
#include<iostream> #include<cmath> #include<cstring> using namespace std; int n,m; char map[62][62]; struct Rob { int ri,rj; char d; }rob; void zhiling(char ch) { if(ch=='R'){ if(rob.d=='N')rob.d='E'; else if(rob.d=='E')rob.d='S'; else if(rob.d=='S')rob.d='W'; else if(rob.d=='W')rob.d='N'; } else if(ch=='L'){ if(rob.d=='N')rob.d='W'; else if(rob.d=='W')rob.d='S'; else if(rob.d=='S')rob.d='E'; else if(rob.d=='E')rob.d='N'; } else if(ch=='F'){ if(rob.d=='N'){ if(map[rob.ri-1][rob.rj]==' '&&rob.ri>0)rob.ri --; } else if(rob.d=='W'){ if(map[rob.ri][rob.rj-1]==' '&&rob.rj>0)rob.rj --; } else if(rob.d=='S'){ if(map[rob.ri+1][rob.rj]==' '&&rob.ri<n-1)rob.ri ++; } else if(rob.d=='E'){ if(map[rob.ri][rob.rj+1]==' '&&rob.rj<m-1)rob.rj ++; } } } int main() { int si,sj,i,j; char ch; while(cin>>n>>m) { string s; cin.get(); for(i=0;i<n;i++) cin.getline(map[i],60); cin>>si>>sj; rob.d='N';rob.ri=si;rob.rj=sj; while(1) { cin>>ch; s.push_back(ch); if(ch=='Q') break; } for(i=0;s[i]!='Q';i++) { zhiling(s[i]); } cout<<rob.ri+1<<" "<<rob.rj+1<<" "<<rob.d<<endl; } return 0; }
相关文章推荐
- zoj Nov. 2012 月赛 F题 Japanese Mahjong III
- ZOJ 1149(多重背包)
- ZOJ 3993 Safest Buildings (思路)
- ZOJ 3785-What day is that day 解题报告
- Kinds of Fuwas ——zoj 2975
- ZOJ 3334 Body Check (二分)
- ZOJ 3962 Seven Segment Display (数位 DP)
- ZOJ 3964 Yet Another Game of Stones (博弈)
- ZOJ 3965 Binary Tree Restoring (递归)
- ZOJ 3961 Let's Chat (双指针 + 区间交)
- ZOJ 3958 Cooking Competition
- ZOJ 3959 Problem Preparation
- ZOJ 3960 What Kind of Friends Are You?(哈希)
- ZOJ 3963 Heap Partition(贪心)
- ZOJ 3952 Fibonacci Sequence Chicken Edition
- ZOJ 3953 Intervals (贪心)
- ZOJ 3954 Seven-Segment Display (预处理)
- ZOJ 3957 Knuth-Morris-Pratt Algorithm
- ZOJ 3956 Course Selection System (dp)
- ZOJ 3955 Saddle Point (树状数组)