Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#define MAX 12
#define INFTY 1 << 28
using namespace std;

class CMap{
public:
	int m[MAX][MAX];
	vector< pair<int, int> > vHist;

	CMap(){ memset( m, 0, sizeof(*m) * sizeof(**m) ); }
	void PassParticle(int i, int j){
		const int di[] = {0,-1,0,1,0};
		const int dj[] = {0,0,1,0,-1};

		for(int k = 0; k < sizeof(di)/sizeof(*di); ++k)
			m[i+di[k]][j+dj[k]] = (m[i+di[k]][j+dj[k]] + 1) % 2;

		vHist.push_back( make_pair( i, j ) );
	}
	bool NoLight() const {
		for(int i = 1; i < MAX - 1; ++i)
			for(int j = 1; j < MAX - 1; ++j)
				if( m[i][j] ) return false;
		return true;
	}
	void Print() const {
		for(int i = 1; i < MAX - 1; ++i){
			cout << m[i][1];
			for(int j = 2; j < MAX - 1; ++j)
				cout << ' ' << m[i][j];
			cout << '\n';
		}
	}
	void PrintAns() const {
		int a[MAX][MAX] = {{0,},};
		for( unsigned int i = 0; i < vHist.size(); ++i)
			a[vHist[i].first][vHist[i].second] = 1;

		for(int i = 1; i < MAX - 1; ++i){
			cout << a[i][1];
			for(int j = 2; j < MAX - 1; ++j)
				cout << ' ' << a[i][j];
			cout << '\n';
		}
	}
	bool operator==(const CMap &t) const {
		for(int i = 1; i < MAX - 1; ++i)
			for(int j = 1; j < MAX - 1; ++j)
				if( t.m[i][j] != m[i][j] )
					return false;
		return true;
	}
};
void BFS(CMap &stm, CMap &ret){
	vector< CMap > q;

	q.push_back( stm );

	while( !q.empty() ){
		CMap M = q[0];
		q.erase( q.begin() );

		if( M.NoLight() ){
			ret = M;
			break;
		}

		for(int i = 1; i < MAX - 1; ++i){
			for(int j = 1; j < MAX - 1 ; ++j){
				CMap add;
				int cnt1 = 0;
				const int di[] = {-1,0,1,0};
				const int dj[] = {0,1,0,-1};

				for(int k = 0; k < sizeof(di)/sizeof(*di); ++k)
					if( M.m[i+di[k]][j+dj[k]] ) ++cnt1;

				if( cnt1 >= 3 )
				{
					add = M;
					add.PassParticle( i, j );
					if( q.end() == find( q.begin(), q.end(), add ) )
						q.push_back( add );
				}
			}
		}
	}
}
int main(void){
	int n;

	cin >> n;
	for( int D = 0; D < n; ++D ){
		CMap M;
		CMap Answer;

		for(int i = 1; i < MAX - 1; ++i)
			for(int j = 1; j < MAX - 1 ; ++j)
				cin >> M.m[i][j];

		BFS( M, Answer );

		Answer.PrintAns();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void BFS(CMap&, CMap&)':
a.cc:86:60: error: no matching function for call to 'find(std::vector<CMap>::iterator, std::vector<CMap>::iterator, CMap&)'
   86 |                                         if( q.end() == find( q.begin(), q.end(), add ) )
      |                                                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:86:60: note:   '__gnu_cxx::__normal_iterator<CMap*, std::vector<CMap> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   86 |                                         if( q.end() == find( q.begin(), q.end(), add ) )
      |                                                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~