Language: C++

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807
int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int h,w,a[1002][1002],ans;
queue<pair<int,int>> v;

signed main() {
    cin >> h >> w;
    rep(i,h+2) a[i][0] = a[i][w+1] = 1;
    rep(i,w+2) a[0][i] = a[h+1][i] = 1;
    rep1(i,h) {
        string s;
        cin >> s;
        rep1(j,w) {
            if (s[j-1] == '.') a[i][j] = 0;
            else a[i][j] = 1;
        }
    }
    rep1(i,h) {
        rep1(j,w) {
            int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
            if (a[i][j]) {
                rep(k,4) if (!a[i+dy[k]][j+dx[k]]) {
                        v.push(mp(i+dy[k],j+dx[k]));
                    }
            }
        }
    }
    while(!v.empty()) {
        queue<pair<int,int>> tmp,hoge=v;
        while(!v.empty()) {
            int i = v.front().fi, j = v.front().se;v.pop();
            if (a[i][j]) continue;
            a[i][j] = 1;
            int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
            rep(k,4) if (!a[i+dy[k]][j+dx[k]]) {
                    tmp.push(mp(i+dy[k],j+dx[k]));
                }
        }
        while(!hoge.empty()) {
            int i = hoge.front().fi, j = hoge.front().se;
            if (!a[i][j]) a[i][j] = 1;
            hoge.pop();
        }
        v = tmp;
#include <bits/stdc++.h>
        using namespace std;

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807
        int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
        int lcm(int a,int b){return a/gcd(a,b)*b;}

        int h,w,a[1002][1002],ans;
        queue<pair<int,int>> v;

        signed main() {
            cin >> h >> w;
            rep(i,h+2) a[i][0] = a[i][w+1] = 1;
            rep(i,w+2) a[0][i] = a[h+1][i] = 1;
            rep1(i,h) {
                string s;
                cin >> s;
                rep1(j,w) {
                    if (s[j-1] == '.') a[i][j] = 0;
                    else a[i][j] = 1;
                }
            }
            rep1(i,h) {
                rep1(j,w) {
                    int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
                    if (a[i][j]) {
                        rep(k,4) if (!a[i+dy[k]][j+dx[k]]) {
                                v.push(mp(i+dy[k],j+dx[k]));
                            }
                    }
                }
            }
            while(!v.empty()) {
                queue<pair<int,int>> tmp,hoge;
                while(!v.empty()) {
                    int i = v.front().fi, j = v.front().se;v.pop();
                    if (a[i][j]) continue;
                    a[i][j] = 1;
                    int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
                    rep(k,4) if (!a[i+dy[k]][j+dx[k]]) {
                            tmp.push(mp(i+dy[k],j+dx[k]));
                        }
                }
                hoge = tmp;
                while(!hoge.empty()) {
                    int i = hoge.front().fi, j = hoge.front().se;
                    if (!a[i][j]) a[i][j] = 1;
                    hoge.pop();
                }
                v = tmp;
                ans++;
            }
            cout << ans << endl;
        }








        ans++;
    }
    cout << ans << endl;
}









Compiler output:
a.cc: In function 'int main()':
a.cc:84:29: error: a function-definition is not allowed here before '{' token
   84 |         int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
      |                             ^
a.cc:85:29: error: a function-definition is not allowed here before '{' token
   85 |         int lcm(int a,int b){return a/gcd(a,b)*b;}
      |                             ^
a.cc:90:20: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   90 |         signed main() {
      |                    ^~
a.cc:90:20: note: remove parentheses to default-initialize a variable
   90 |         signed main() {
      |                    ^~
      |                    --
a.cc:90:20: note: or replace parentheses with braces to value-initialize a variable
a.cc:90:23: error: a function-definition is not allowed here before '{' token
   90 |         signed main() {
      |                       ^