Language: C++

#include<iostream>
#include<set>
using namespace std;
int n,m;
int start[8];
int end[8];
int result=0;

bool allPassed(set<int> passPoint){
	for(int i =1;i<=n;i++){
		if(passPoint.count(i)==0){
			return 0;
		}
	}
	return 1;
}

void printSet(set<int> s){
	set<int>::iterator iter = s.begin();
	while (iter!=s.end()){
		cout<<*iter<<"\t";
		iter++;
	}
	cout<<endl;
}
/**
往前走一步，current表示当前节点
passPoint 表示已经遍历过的点
passEdge 表示已经遍历过的边 
*/
void goOneStep(int current,set<int> passPoint,set<int>  passEdge){
	/**每走一步，需要判断当前这个点有哪些下一步可以走
		但是已经遍历过的点不能再走了
		已经用过的边，不能再走了
		往前走一步，把走过的点和边记录下来
		如果判断所有的点走过，那么就可以返回，并且结果+1
		如果没有边可以走，那么也返回，但是结果不+1 
	*/
	if(allPassed(passPoint)) {
		result ++;
		cout << "success!\n";
		return ;
	}
	
	for(int i=0;i<m;i++){
		int next;
		if(passEdge.count(i)>0){
			continue;
		}

		if(start[i]==current ){
			next=end[i];
		}else if(end[i] == current){
			next = start[i];
		}else{
			continue;
		} 
		if(passPoint.count(next)>0){
			continue;
		}
		set<int> thisPassPoint =  passPoint;
		thisPassPoint.insert(next);
		set<int> thisPassEdge = passEdge;
		thisPassEdge.insert(i);
		//cout<<"from:"<<current<<"to"<<next<<endl;

		goOneStep(next,thisPassPoint,thisPassEdge);
	}
	
}



int main(){
	set<int> passPoint,passEdge;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin >> start[i] >> end[i];
	}
	passPoint.insert(1);
	goOneStep(1,passPoint,passEdge);
	cout<<result;
	
}

Compiler output:
a.cc: In function 'void goOneStep(int, std::set<int>, std::set<int>)':
a.cc:52:30: error: reference to 'end' is ambiguous
   52 |                         next=end[i];
      |                              ^~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/14/bits/range_access.h:36:
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:5: note:                 'int end [8]'
    6 | int end[8];
      |     ^~~
a.cc:53:26: error: reference to 'end' is ambiguous
   53 |                 }else if(end[i] == current){
      |                          ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:5: note:                 'int end [8]'
    6 | int end[8];
      |     ^~~
a.cc: In function 'int main()':
a.cc:78:36: error: reference to 'end' is ambiguous
   78 |                 cin >> start[i] >> end[i];
      |                                    ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:5: note:                 'int end [8]'
    6 | int end[8];
      |     ^~~