Guest User

Untitled

a guest
Jun 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <bitset>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int m,n,s,w,e,x,y;
  9. bitset<100> nf, ef, wf ,sf;
  10. while(cin >> m >> n >> s >> w >> e >> x >> y && m){
  11. nf.reset();
  12. ef.reset();
  13. wf.reset();
  14. sf.reset();
  15. x--;
  16. y--;
  17. int f,walked=0;
  18. while(n-- && cin >> f)
  19. nf[f-1]=true;
  20. while(s-- && cin >> f)
  21. sf[f-1]=true;
  22. while(w-- && cin >> f)
  23. wf[f-1]=true;
  24. while(e-- && cin >> f)
  25. ef[f-1]=true;
  26. while(walked++!=m*m+1){
  27. if(x >= m || y >= m || x < 0 || y < 0){
  28. cout << "Be careful" << endl;
  29. break;
  30. }else if((nf[x]^sf[x])||(wf[y]^ef[y])){
  31. int oy=y;
  32. if(nf[x]^sf[x])
  33. y+=nf[x]?-1:1;
  34. if(wf[oy]^ef[oy])
  35. x+=ef[oy]?-1:1;
  36. }else{
  37. cout << x+1 << ' ' << y+1 << endl;
  38. break;
  39. }
  40. }
  41. if(walked>=m*m+1)
  42. cout << "Busy Bob" << endl;
  43. }
  44. return 0;
  45. }
Add Comment
Please, Sign In to add comment