Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- char a[100][100];
- int n,m, us[100][100], b[10] = {1, 0 , -1, 0, 0, 1, 0, -1}, col;
- void dfs (int x, int y){
- if (!x || !y || x > n || y > m) return;
- col++;
- us[x][y] = 1;
- for (int i = 0; i < 8; i++){
- if (a[x + b[i]][y + b[i + 1]] == '.' && !us[x + b[i]][y + b[i + 1]]){
- dfs(x + b[i], y + b[i + 1]);
- }
- }
- }
- int main (){
- cin >> n;
- m = n;
- for (int i = 1; i <= n; i++){
- for (int j = 1; j <= m; j++){
- cin >> a[i][j];
- }
- }
- int x, y;
- cin >> x >> y;
- dfs(x, y);
- cout << col;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement