Language: C++

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int h,w,ans,dx[]={0,1,0,-1},dy[]={-1,0,1,0};
char m[1111][1111];
set<pair< pair<int,int>,pair<int,int> > > aa;

bool isin(int y,int x){
	return y>=0&&x>=0&&y<h&&x<w;
}

bool difc(char c,char nc){
	return c!=nc;
}

void dfs(int y,int x,int cur[][],pair<int,int> mo){
	//debug(y,x);
	for(int i=0;i<4;i++){
		int ny=y+dy[i],nx=x+dx[i];
		if(isin(ny,nx)==0)continue;
		if(difc(m[y][x],m[ny][nx])==0)continue;
		if(cur[ny][nx]==1)continue;
		cur[y][x]++;
		//if(m[y][x]=='#')ans++;
		//for(auto x:cur)cout<<x.fi<<','<<x.se<<' ';
		dfs(ny,nx,cur[][],mo);
	}
	if(m[y][x]=='.'){
		aa.ins(mp(mo,mp(y,x)));
	}
	return;
}

main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>m[i][j];
		}
	}
	rep(i,h){
		rep(j,w){
			if(m[i][j]=='#'){
				set<pair<int,int> > cur;
				use[h][w]={};
				use[i][j]++;
				cur.ins({i,j});
				dfs(i,j,use[][],mp(i,j));
			}
		}
	}
	dump(aa.size());
}


Compiler output:
a.cc:12:9: warning: "INT_MAX" redefined
   12 | #define INT_MAX LLONG_MAX
      |         ^~~~~~~
In file included from /usr/include/c++/14/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:38,
                 from a.cc:8:
/usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:120:9: note: this is the location of the previous definition
  120 | #define INT_MAX __INT_MAX__
      |         ^~~~~~~
a.cc:64:26: error: declaration of 'cur' as multidimensional array must have bounds for all dimensions except the first
   64 | void dfs(int y,int x,int cur[][],pair<int,int> mo){
      |                          ^~~
a.cc:64:33: error: expected ')' before ',' token
   64 | void dfs(int y,int x,int cur[][],pair<int,int> mo){
      |         ~                       ^
      |                                 )
a.cc:64:48: error: invalid declarator before 'mo'
   64 | void dfs(int y,int x,int cur[][],pair<int,int> mo){
      |                                                ^~
a.cc:82:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   82 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:93:33: error: 'use' was not declared in this scope; did you mean 'se'?
   93 |                                 use[h][w]={};
      |                                 ^~~
      |                                 se
a.cc:96:45: error: expected primary-expression before ']' token
   96 |                                 dfs(i,j,use[][],mp(i,j));
      |                                             ^
a.cc:96:47: error: expected primary-expression before ']' token
   96 |                                 dfs(i,j,use[][],mp(i,j));
      |                                               ^