Language: C++

#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e8)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

int N,M;
int H, W;

int A[1000][1000];
int visited[1000][1000] = {0};
int cou[1001][1001] = {INF};
int ans = 0;

int main()
{
	cin >> H >> W;
	int chang[H][W];
	REP(i, H)
	{
		string s;
		cin >> s;
		REP(j, W)
		{
			if(s[j]=='#'){
				A[i][j] = 0;
				cou[i+1][j+1] = 0;
			}else{
				A[i][j] = 1;
				visited[i][j] = 1;
				cou[i+1][j+1] = INF;	
			}
			chang[i][j] = 0;
		}
	}

	int ans= 0;
	while (1)
	{
		bool flag = false;
		ans++;

		REP(i,H){
			REP(j,W){
				chang[i][j] = 0;
			}
		}
		
		REP(i,H)
		{
			REP(j,W){
				if(A[i][j]==0){
					if(chang[i][j]==0&&A[i-1][j]==1){
					A[i - 1][j] = 0;
					chang[i - 1][j] = 1;
					}
					if(chang[i][j]==0&&A[i+1][j]==1){
					A[i + 1][j] = 0;
					chang[i + 1][j] = 1;
					}
					if(chang[i][j]==0&&A[i][j-1]==1){
					A[i][j-1] = 0;
					chang[i][j-1] = 1;
					}
					if(chang[i][j]==0&&A[i][j+1]==1){
					A[i][j+1] = 0;
					chang[i][j+1] = 1;
					}
				}
			}
		}
		
		REP(i,H)
		{
			REP(j,W){
				if(A[i][j]==1){
					flag = true;
				}
			}
		}
		if(!flag){
			break;
		}
		
	}

	cout << ans << endl;








	return 0;
}#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e8)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

int N,M;
int H, W;

int A[1000][1000];
int visited[1000][1000] = {0};
int cou[1001][1001] = {INF};
int ans = 0;

int main()
{
	cin >> H >> W;
	int chang[H][W];
	REP(i, H)
	{
		string s;
		cin >> s;
		REP(j, W)
		{
			if(s[j]=='#'){
				A[i][j] = 0;
				cou[i+1][j+1] = 0;
			}else{
				A[i][j] = 1;
				visited[i][j] = 1;
				cou[i+1][j+1] = INF;	
			}
			chang[i][j] = 0;
		}
	}

	int ans= 0;
	while (1)
	{
		bool flag = false;
		ans++;

		REP(i,H){
			REP(j,W){
				chang[i][j] = 0;
			}
		}
		
		REP(i,H)
		{
			REP(j,W){
				if(A[i][j]==0){
					if(chang[i][j]==0&&A[i-1][j]==1){
					A[i - 1][j] = 0;
					chang[i - 1][j] = 1;
					}
					if(chang[i][j]==0&&A[i+1][j]==1){
					A[i + 1][j] = 0;
					chang[i + 1][j] = 1;
					}
					if(chang[i][j]==0&&A[i][j-1]==1){
					A[i][j-1] = 0;
					chang[i][j-1] = 1;
					}
					if(chang[i][j]==0&&A[i][j+1]==1){
					A[i][j+1] = 0;
					chang[i][j+1] = 1;
					}
				}
			}
		}
		
		REP(i,H)
		{
			REP(j,W){
				if(A[i][j]==1){
					flag = true;
				}
			}
		}
		if(!flag){
			break;
		}
		
	}

	cout << ans << endl;








	return 0;
}

Compiler output:
a.cc:129:2: error: stray '#' in program
  129 | }#include <iostream>
      |  ^
a.cc:14:14: error: narrowing conversion of '1.0e+8' from 'double' to 'int' [-Wnarrowing]
   14 | #define INF (1e8)
      |             ~^~~~
a.cc:44:24: note: in expansion of macro 'INF'
   44 | int cou[1001][1001] = {INF};
      |                        ^~~
a.cc:129:3: error: 'include' does not name a type
  129 | }#include <iostream>
      |   ^~~~~~~
a.cc:148:5: error: redefinition of 'template<class T> int vector_finder(std::vector<_Tp>, T)'
  148 | int vector_finder(std::vector<T> vec, T number) {
      |     ^~~~~~~~~~~~~
a.cc:20:5: note: 'template<class T> int vector_finder(std::vector<_Tp>, T)' previously declared here
   20 | int vector_finder(std::vector<T> vec, T number) {
      |     ^~~~~~~~~~~~~
a.cc:159:5: error: redefinition of 'int gcd(int, int)'
  159 | int gcd(int a,int b){
      |     ^~~
a.cc:31:5: note: 'int gcd(int, int)' previously defined here
   31 | int gcd(int a,int b){
      |     ^~~
a.cc:167:5: error: redefinition of 'int N'
  167 | int N,M;
      |     ^
a.cc:39:5: note: 'int N' previously declared here
   39 | int N,M;
      |     ^
a.cc:167:7: error: redefinition of 'int M'
  167 | int N,M;
      |       ^
a.cc:39:7: note: 'int M' previously declared here
   39 | int N,M;
      |       ^
a.cc:168:5: error: redefinition of 'int H'
  168 | int H, W;
      |     ^
a.cc:40:5: note: 'int H' previously declared here
   40 | int H, W;
      |     ^
a.cc:168:8: error: redefinition of 'int W'
  168 | int H, W;
      |        ^
a.cc:40:8: note: 'int W' previously declared here
   40 | int H, W;
      |        ^
a.cc:170:5: error: redefinition of 'int A [1000][1000]'
  170 | int A[1000][1000];
      |     ^
a.cc:42:5: note: 'int A [1000][1000]' previously declared here
   42 | int A[1000][1000];
      |     ^
a.cc:171:5: error: redefinition of 'int visited [1000][1000]'
  171 | int visited[1000][1000] = {0};
      |     ^~~~~~~
a.cc:43:5: note: 'int visited [1000][1000]' previously defined here
   43 | int visited[1000][1000] = {0};
      |     ^~~~~~~
a.cc:172:5: error: redefinition of 'int cou [1001][1001]'
  172 | int cou[1001][1001] = {INF};
      |     ^~~
a.cc:44:5: note: 'int cou [1001][1001]' previously defined here
   44 | int cou[1001][1001] = {INF};
      |     ^~~
a.cc:173:5: error: redefinition of 'int ans'
  173 | int ans = 0;
      |     ^~~
a.cc:45:5: note: 'int ans' previously defined here
   45 | int ans = 0;
      |     ^~~
a.cc:175:5: error: redefinition of 'int main()'
  175 | int main()
      |     ^~~~
a.cc:47:5: note: 'int main()' previously defined here
   47 | int main()
      |     ^~~~