Language: C++

#include <cstdio>
#include <set>
#include <vector>
#include <ctype.h>
#include <iostream>

bool is_find(std::vector<int> pieace,std::vector<int> cadidate)
{
	for(int i=0;i<8;i++)
		if(pieace[i]!=cadidate[i]) return false;
	return true;
}
int solve(std::vector<int> init_pieace)
{
	int total_step = 0;
	std::vector<int> target_list = {0,1,2,3,4,5,6,7};

	std::set<std::vector<int>> frontier;
	frontier.insert(init_pieace);

	std::set<std::vector<int>> previous_frontier;
	int step = 0;
	while(true)
	{
		std::set<std::vector<int>> next_frontier;
//		std::cout << "step1:"<< step << "\t" << frontier.size() << "\t" << next_frontier.size() << "\t" <<  previous_frontier.size() << std::endl;
		for(auto p : frontier)
		{
/*
			for(auto x : p)
				std::cout << x << ',';
			std::cout << std::endl;
*/
			if(is_find(target_list,p)) return step;
			int zero_position=0;
			for(int i=0;i<8;i++)
			{
				if(p[i]==0)
				{
					zero_position = i;
					break;
				}
			}
//			std::cout << "zero:" << zero_position << std::endl;
			int relative = zero_position%4;

			std::vector<int> new_peiace=p;
			int swap = new_peiace[relative];
			new_peiace[relative] = new_peiace[relative+4];
			new_peiace[relative+4] = swap;
//			if(previous_frontier.count(new_peiace)==0)
			if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
				next_frontier.insert(new_peiace);

			if(0<=relative && relative<3)
			{
				std::vector<int> new_peiace=p;
				int swap = new_peiace[zero_position];
				new_peiace[zero_position] = new_peiace[zero_position+1];
				new_peiace[zero_position+1] = swap;
//				if(previous_frontier.count(new_peiace)==0)
				if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
					next_frontier.insert(new_peiace);
			}

			if(0<relative && relative<=3)
			{
				std::vector<int> new_peiace=p;
				int swap = new_peiace[zero_position];
				new_peiace[zero_position] = new_peiace[zero_position-1];
				new_peiace[zero_position-1] = swap;
//				if(previous_frontier.count(new_peiace)==0)
				if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
					next_frontier.insert(new_peiace);
			}
		}
/*
		if(next_frontier.size()==0)
		{
			std::cout << "somwthing wrong" << std::endl;
			exit(1);
		}
        std::cout << "------------------------------------------------------------------------------" << std::endl;
		for(auto p : next_frontier)
		{
			for(auto x : p)
				std::cout << x << ',';
			std::cout << std::endl;
		}
		std::cout << "==============================================================================" << std::endl;
		std::cout << "step2:"<< step << "\t" << frontier.size() << "\t" << next_frontier.size() << "\t" <<  previous_frontier.size() << std::endl;
*/
		previous_frontier = frontier;
		frontier = next_frontier;
		step++;
	}
}
int main()
{
	char cline[16];
	std::cin.getline(cline, sizeof(cline));
	while(0<=cline[0]-'0' && cline[0]-'0'<8)
	{
		std::vector<int> pieace(8);
		int cp = 0;
		for(int i=0;i<16;i++)
			if(isdigit(cline[i]))
				pieace[cp++]=cline[i]-'0';
		std::cout << solve(pieace) << std::endl;
		std::cin.getline(cline, sizeof(cline));
	}
}

Compiler output:
a.cc: In function 'int solve(std::vector<int>)':
a.cc:52:37: error: no matching function for call to 'find(std::set<std::vector<int> >::iterator, std::set<std::vector<int> >::iterator, std::vector<int>&)'
   52 |                         if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
      |                            ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:5:
/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, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_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:52:37: note:   'std::_Rb_tree_const_iterator<std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
   52 |                         if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
      |                            ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:62:45: error: no matching function for call to 'find(std::set<std::vector<int> >::iterator, std::set<std::vector<int> >::iterator, std::vector<int>&)'
   62 |                                 if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
      |                                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_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:62:45: note:   'std::_Rb_tree_const_iterator<std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
   62 |                                 if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
      |                                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:73:45: error: no matching function for call to 'find(std::set<std::vector<int> >::iterator, std::set<std::vector<int> >::iterator, std::vector<int>&)'
   73 |                                 if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
      |                                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_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:73:45: note:   'std::_Rb_tree_const_iterator<std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
   73 |                                 if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
      |                                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~