Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- bool checkBoundries(int r , int c , int x , int y);
- void pathesOfWolf(vector< vector<char> > arr (rows , vector<char>(columns)));
- int main()
- {
- int rows , columns;
- cin >> rows >> columns;
- bool f = false;
- char c;
- vector< vector<char> > arr (rows , vector<char>(columns));
- vector < pair<int,int> >wolfs;
- vector < vector<bool> > visited(rows , vector<bool>(columns, false));
- for(int i = 0; i < rows; i++)
- {
- for (int j = 0; j < columns; j++)
- {
- cin >> c;
- if(c == 'W')
- {
- wolfs.push_back(make_pair(i,j));
- }
- arr[i][j] = c;
- }
- }
- for( int i = 0; i < wolfs.size(); i ++)
- {
- int x , y;
- x = wolfs.at(wolfs.size()-1).first;
- y = wolfs.at(wolfs.size()-1).second;
- if(checkBoundries(rows , columns ,x + 1 , y) && arr[x + 1][y] == 'S' )
- {
- f = true;
- break;
- }
- else if(checkBoundries(rows , columns ,x , y + 1) && arr[x ][y +1] == 'S' )
- {
- f = true;
- break;
- }
- else if(checkBoundries(rows , columns ,x -1 , y ) && arr[x -1][y] == 'S' )
- {
- f = true;
- break;
- }
- else if(checkBoundries(rows , columns ,x , y - 1) && arr[x][y - 1] == 'S' )
- {
- f = true;
- break;
- }
- wolfs.erase(wolfs.end() - 1);
- }
- if(f){
- cout << "No";
- }
- else{
- }
- }
- bool checkBoundries(int r , int c , int x , int y)
- {
- if( x < 0 || x >= r || y < 0 || y >= c)
- {
- return false;
- }
- return true ;
- }
- void pathesOfWolf(vector< vector<char> > arr (rows , vector<char>(columns))){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement