Language: C++

#include<iostream>
#include<cstring>
using namespace std;
const int N = 310;
char s[N][N];
int id[N][N];
int is_empty[N];	
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	memset(id,0,sizeof(id));
	memset(is_empty,true,sizeof(is_empty));
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>s[i][j];
			if(s[i][j]=='#'){
				is_empty[i]=false;
			}
		}
	}

	int cnt=1;
	for(int i=1;i<=n;i++){
		if(!is_empty[i]){
			for(int j=1;j<=m;j++){
				if(s[i][j]=='#'){
					id[i][j]=cnt++;
				}
			}
			int last=0;
			for(int j=1;j<=m;j++){
				if(s[i][j]=='#'){
					last=id[i][j];
				}
				else{
					id[i][j]=last;
				}
			}
			last=id[i][m];
			for(int j=m;j>=1;j--){
				if(s[i][j]=='#'){
					last=id[i][j];
				}
				else{
					id[i][j]=last;
				}
			}
		}
	}
	for(int i=2;i<=n;i++){
		if(is_empty[i]){
			is_empty[i]=false;
			for(int j=1;j<=m;j++){
				id[i][j]=id[i-1][j];
			}
		}
	}
	for(int i=n-1;i>=1;i--){
		if(is_empty[i]){
			is_empty[i]=false;
			for(int j=1;j<=m;j++){
				id[i][j]=id[i+1][j];
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cout<<id[i][j]<<' ';
		}
		cout<<endl;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: reference to 'is_empty' is ambiguous
   12 |         memset(is_empty,true,sizeof(is_empty));
      |                ^~~~~~~~
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~
a.cc:12:37: error: reference to 'is_empty' is ambiguous
   12 |         memset(is_empty,true,sizeof(is_empty));
      |                                     ^~~~~~~~
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~
a.cc:19:33: error: reference to 'is_empty' is ambiguous
   19 |                                 is_empty[i]=false;
      |                                 ^~~~~~~~
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~
a.cc:26:21: error: reference to 'is_empty' is ambiguous
   26 |                 if(!is_empty[i]){
      |                     ^~~~~~~~
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~
a.cc:53:20: error: reference to 'is_empty' is ambiguous
   53 |                 if(is_empty[i]){
      |                    ^~~~~~~~
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~
a.cc:54:25: error: reference to 'is_empty' is ambiguous
   54 |                         is_empty[i]=false;
      |                         ^~~~~~~~
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~
a.cc:61:20: error: reference to 'is_empty' is ambiguous
   61 |                 if(is_empty[i]){
      |                    ^~~~~~~~
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~
a.cc:62:25: error: reference to 'is_empty' is ambiguous
   62 |                         is_empty[i]=false;
      |                         ^~~~~~~~
/usr/include/c++/14/type_traits:913:12: note: candidates are: 'template<class _Tp> struct std::is_empty'
  913 |     struct is_empty
      |            ^~~~~~~~
a.cc:7:5: note:                 'int is_empty [310]'
    7 | int is_empty[N];
      |     ^~~~~~~~