Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int>> ans(h,vector<int>(w,-1));
    char s;
    int count = 1;
    vector<P> pos(k);
    rep(i,h){
        rep(j,w){
            cin >> s;
            if (s =='#'){
                ans[i][j] = count;
                pos[count-1] = P(i,j);
                count++;
            }
        }
    }
    
    
    
    for (auto p:pos){
        
        int fill = ans[p.first][p.second];
        cout << fill << endl;
        int l1 = p.first;
        int l2 = p.second;
        int l3 = p.first;
        int l4 = p.second;
        
        int loc[] = {l1,l2,l3,l4};
        bool north,east,west,south;
        north =true;
        east = true;
        west = true;
        south = true;
        while(north||east||west||south){

            
            if (west){
                if(loc[1]==0){
                    west = false;continue;
                }
                bool cnt = false;
                rep(i,loc[2]-loc[0]+1){
                    if (ans[i+loc[0]][loc[1]-1]  > 0 ){west = false}
                }
                if (west){
                rep(i,loc[2]-loc[0]+1){
                    ans[i+loc[0]][loc[1]-1] = fill;
                }
                    
                loc[1]--;
                }
            }

            
            if (east){
                if(loc[3]==w-1){
                    east = false;continue;
                }
                rep(i,loc[2]-loc[0]+1){
                    if (ans[i+loc[0]][loc[3]+1]  > 0 ){east = false;}
                }
                if (east){
                rep(i,loc[2]-loc[0]+1){
                    ans[i+loc[0]][loc[3]+1] = fill;
                }
                loc[3]++;
                }
            }
            

            
            
            
            if (north){
                if(loc[0]==0){
                    north = false;continue;
                }
                rep(i,loc[3]-loc[1]+1){
                    if (ans[loc[0]-1][loc[3]-loc[1]+i] > 0 ){north = false;}
                }
                if (north){
                rep(i,loc[3]-loc[1]+1){
                    ans[loc[0]-1][loc[3]-loc[1]+i] = fill;
                }
                loc[0]--;
                }
            }
            if (south){
                if(loc[2]==h-1){
                    south = false;continue;
                }
                rep(i,loc[3]-loc[1]+1){
                    if (ans[loc[2]+1][loc[3]-loc[1]+i]  > 0 ){south = false;}
                }
                if (south){
                rep(i,loc[3]-loc[1]+1){
                    ans[loc[2]+1][loc[3]-loc[1]+i] = fill;
                }
                loc[2]++;
                }
            }
        }
    }
    
    rep(i,h){
        rep(j,w){
            cout << ans[i][j];
        }
        cout << endl;
    }
    rn 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:68: error: expected ';' before '}' token
   79 |                     if (ans[i+loc[0]][loc[1]-1]  > 0 ){west = false}
      |                                                                    ^
      |                                                                    ;