Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5. bool checkBoundries(int r , int c , int x , int y);
  6. void pathesOfWolf(vector< vector<char> > arr (rows , vector<char>(columns)));
  7.  
  8.  
  9. int main()
  10. {
  11. int rows , columns;
  12. cin >> rows >> columns;
  13. bool f = false;
  14. char c;
  15. vector< vector<char> > arr (rows , vector<char>(columns));
  16. vector < pair<int,int> >wolfs;
  17. vector < vector<bool> > visited(rows , vector<bool>(columns, false));
  18. for(int i = 0; i < rows; i++)
  19. {
  20. for (int j = 0; j < columns; j++)
  21. {
  22. cin >> c;
  23. if(c == 'W')
  24. {
  25. wolfs.push_back(make_pair(i,j));
  26. }
  27. arr[i][j] = c;
  28. }
  29. }
  30. for( int i = 0; i < wolfs.size(); i ++)
  31. {
  32. int x , y;
  33. x = wolfs.at(wolfs.size()-1).first;
  34. y = wolfs.at(wolfs.size()-1).second;
  35. if(checkBoundries(rows , columns ,x + 1 , y) && arr[x + 1][y] == 'S' )
  36. {
  37. f = true;
  38. break;
  39. }
  40. else if(checkBoundries(rows , columns ,x , y + 1) && arr[x ][y +1] == 'S' )
  41. {
  42. f = true;
  43. break;
  44. }
  45. else if(checkBoundries(rows , columns ,x -1 , y ) && arr[x -1][y] == 'S' )
  46. {
  47. f = true;
  48. break;
  49. }
  50. else if(checkBoundries(rows , columns ,x , y - 1) && arr[x][y - 1] == 'S' )
  51. {
  52. f = true;
  53. break;
  54. }
  55. wolfs.erase(wolfs.end() - 1);
  56. }
  57. if(f){
  58. cout << "No";
  59. }
  60. else{
  61.  
  62.  
  63. }
  64.  
  65.  
  66.  
  67. }
  68. bool checkBoundries(int r , int c , int x , int y)
  69. {
  70. if( x < 0 || x >= r || y < 0 || y >= c)
  71. {
  72. return false;
  73. }
  74. return true ;
  75. }
  76.  
  77. void pathesOfWolf(vector< vector<char> > arr (rows , vector<char>(columns))){
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement