#include<bits/stdc++.h> #define ouo ios_base::sync_with_stdio(false), cin.tie(0) #define ll long long #define db double usingnamespace std;
string str; int n, cnt = 0; int g[1005][1005] = {0}; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0};
voidbfs(){ queue<pair<int, int>> que; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (g[i][j] == 1) { que.push({i, j}); // when loop finds availible path, cnt add 1 cnt++; // BFS while (!que.empty()) { auto now = que.front(); que.pop(); // when it checked, fix it to 0 g[now.first][now.second] = 0; // check for next 4 direction for (int k = 0; k < 4; k++) { int x = now.first + dx[k]; int y = now.second + dy[k];
if (x >= 0 && x < n && y >= 0 && y < n && g[x][y]) { que.push({x, y}); } } } } } } }
intmain(){ // init cin >> n; for (int i = 0; i < n; i++) { cin >> str; for (int j = 0; j < n; j++) { if (str[j] == '.') g[i][j] = 1; } } // BFS bfs(); // print count cout << cnt << "\n";