Language: C++

using namespace std;
vector<pair<int, int>> gg = { {1,0},{-1,0},{0,1},{0,-1} };
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> da(h);
	for (int i = 0;i < h;i++)
		cin >> da[i];
	vector<vector<bool>> ju(h+2, vector<bool>(w+2, false));
	for (int i = 0;i < h + 2;i++) {
		ju[i][0] = true;
		ju[i][w + 1] = true;
	}
	for (int i = 0;i < w + 2;i++) {
		ju[0][i] = true;
		ju[h + 1][i] = true;
	}
	vector < pair<int, int>> co(0);
	int hi = 0;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (da[i][j] == '#') {
				ju[i+1][j+1] = true;
				pair<int, int> x = { i+1,j+1 };
				co.push_back(x);
				hi++;
			}
		}
	}
    if(hi==h*w){
        cout << 0 <<endl;
        return 0;
    }
	int ans = 0,ne=0,ko=hi;
	hi = 0;
	while (hi != h * w) {
		ne = ko;
		ko = 0;
		for (int i = 0;i < ne;i++) {
			for (int j = 0;j < 4;j++) {
				if (!ju[co[hi].first + gg[j].first][co[hi].second + gg[j].second]) {
					ju[co[hi].first + gg[j].first][co[hi].second + gg[j].second] = true;
					pair<int, int> x={ co[hi].first + gg[j].first,co[hi].second + gg[j].second };
					co.push_back(x);
					ko++;
				}
			}
			hi++;
		}
		ans++;
		/*for (int i = 0;i < h+2;i++) {
			for (int j = 0;j < w+2;j++) {
				if (ju[i][j])
					cout << 1 << ' ';
				else
					cout << 0 << ' ';
			}
			cout << endl;
		}*/
	}
	cout << ans-1 << endl;


Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<pair<int, int>> gg = { {1,0},{-1,0},{0,1},{0,-1} };
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:5:9: error: 'cin' was not declared in this scope
    5 |         cin >> h >> w;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:6:9: error: 'vector' was not declared in this scope
    6 |         vector<string> da(h);
      |         ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:6:16: error: 'string' was not declared in this scope
    6 |         vector<string> da(h);
      |                ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:6:24: error: 'da' was not declared in this scope
    6 |         vector<string> da(h);
      |                        ^~
a.cc:9:23: error: expected primary-expression before 'bool'
    9 |         vector<vector<bool>> ju(h+2, vector<bool>(w+2, false));
      |                       ^~~~
a.cc:11:17: error: 'ju' was not declared in this scope
   11 |                 ju[i][0] = true;
      |                 ^~
a.cc:15:17: error: 'ju' was not declared in this scope
   15 |                 ju[0][i] = true;
      |                 ^~
a.cc:18:18: error: 'pair' was not declared in this scope
   18 |         vector < pair<int, int>> co(0);
      |                  ^~~~
a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | using namespace std;
a.cc:18:23: error: expected primary-expression before 'int'
   18 |         vector < pair<int, int>> co(0);
      |                       ^~~
a.cc:23:33: error: 'ju' was not declared in this scope; did you mean 'j'?
   23 |                                 ju[i+1][j+1] = true;
      |                                 ^~
      |                                 j
a.cc:24:38: error: expected primary-expression before 'int'
   24 |                                 pair<int, int> x = { i+1,j+1 };
      |                                      ^~~
a.cc:25:33: error: 'co' was not declared in this scope
   25 |                                 co.push_back(x);
      |                                 ^~
a.cc:25:46: error: 'x' was not declared in this scope
   25 |                                 co.push_back(x);
      |                                              ^
a.cc:31:9: error: 'cout' was not declared in this scope
   31 |         cout << 0 <<endl;
      |         ^~~~
a.cc:31:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:21: error: 'endl' was not declared in this scope
   31 |         cout << 0 <<endl;
      |                     ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:41:38: error: 'ju' was not declared in this scope; did you mean 'j'?
   41 |                                 if (!ju[co[hi].first + gg[j].first][co[hi].second + gg[j].second]) {
      |                                      ^~
      |                                      j
a.cc:41:41: error: 'co' was not declared in this scope; did you mean 'ko'?
   41 |                                 if (!ju[co[hi].first + gg[j].first][co[hi].second + gg[j].second]) {
      |                                         ^~
      |                                         ko
a.cc:41:56: error: 'gg' was not declared in this scope
   41 |                                 if (!ju[co[hi].first + gg[j].first][co[hi].second + gg[j].second]) {
      |                                                        ^~
a.cc:43:46: error: expected primary-expression before 'int'
   43 |                                         pair<int, int> x={ co[hi].first + gg[j].first,co[hi].second + gg[j].second };
      |                                              ^~~
a.cc:44:54: error: 'x' was not declared in this scope
   44 |                                         co.push_back(x);
      |                                                      ^
a.cc:61:9: error: 'cout' was not declared in this scope
   61 |         cout << ans-1 << endl;
      |         ^~~~
a.cc:61:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:61:26: error: 'endl' was not declared in this scope
   61 |         cout << ans-1 << endl;
      |                          ^~~~
a.cc:61:26: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:61:31: error: expected '}' at end of input
   61 |         cout << ans-1 << endl;
      |                               ^
a.cc:3:12: note: to match this '{'
    3 | int main() {
      |            ^