Language: C++

#include "bits/stdc++.h"
#include <unordered_set>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define Sort(a) sort(a.begin(),a.end())
#define cSort(a,cmp) sort(a.begin(),a.end(),cmp)
#define reSort(a) sort(a.rbegin(), a.rend())
static const ll llMAX = numeric_limits<long long>::max();
static const int intMAX = numeric_limits<int>::max();
static const ll  llMIN = numeric_limits<long long>::min();
static const int intMIN = numeric_limits<int>::min();
static const ll d_5 = 100000;
static const ll d9_7 = 1000000007;
static const ll d_9 = 1000000000;
static const double PI=3.14159265358979323846;

/*

このBaseedgeクラスをなぜかクラスとして認識してくれない

*/
template<class T>
class Baseedge {
  public:
    int number;
    int v1;
    int v2;
    T length;
    T cost;
    Baseedge(int inputfrom , int inputto, T inputlength,T inputcost,int inputnumber){
      this.v1 = inputfrom;
      this.v2 = inputto;
      this.number = inputnumber;
      this.length = inputlength;
      this.cost = inputcost;
    }
    virtual int nextvertex(int from)=0;
};
template<class T>
class Uniedge : public Baseedge {
  public:

    Uniedge(int inputfrom , int inputto, T inputlength,T inputcost,int inputnumber){
      Baseedge<T>(inputfrom,inputto,inputlength,inputcost, inputnumber);
    }
    
    int nextvertex(int from) override {
      return this.v2;
    }
};
template<class T>
class Biedge : public Baseedge {
  public:

    Biedge(int inputfrom , int inputto, T inputlength,T inputcost,int inputnumber){
      Baseedge<T>(inputfrom,inputto,inputlength,inputcost, inputnumber);
    }
    int nextvertex(int from) override {
      if(this.v1==from){
        return this.v2;
      }else if(this.v2==from){
        return this.v1;
      }else{
        printf("ERROR Invalid number \n");
        return -1;
      }
    }
};
template<class T>
class graph{
  public:
  int n;//ノード数
  
  vector<Baseedge<ll> > es;
  struct vertex{
    int number;
    set<int> edges;
  };
  vector<vertex> vs;
  //constructor
  graph(int input){
    n=input;
    vs=vector<vertex>(n);
    for(int i=0;i<n;i++){
      vs[i].number=i;
    }
  }
  void bind_uni(int from,int to,T len,T cost){
    //1方向につなぐ
    int num=es.size();
    Baseedge<T> newedge = new Uniedge<T>(from,to,len,cost,num);
    es.push_back(newedge);
    vs[from].edges.insert(num);
  }
  void bind_bi(int v1,int v2,T len,T cost){
    //1方向につなぐ
    int num=es.size();
    Baseedge<T> newedge = new Biedge<T>(v1,v2,len,cost,num);
    es.push_back(newedge);
    vs[v1].edges.insert(num);
    vs[v2].edges.insert(num);
  }
  int ans=0;
  void DFS(int now,T length,T cost,set<int> past,int pre=-1){
    if(past.find(now)!=past.end())return;
    past.insert(now);
    if(past.size()==n){
      ans++;
      return ;
    }
    for(auto i:vs[now].edges){
      int next=es[i].nextvertex(now);
      if(next==pre)continue;
      DFS(next,length+es[i].length,cost+es[i].cost,past,now);
    }
  }
  void BFS(int ini){
    struct opera{
      int now;
      int pre;
      T len;
      T cost;
    }
    queue<opera> opes;
    opes.push_back({ini,-1,0,0});
    while(opes.size()>0){
      int now=opes.front().now;
      int pre = opes.front().pre;
      T len = opes.front().len;
      T cost = opes.front().cost;
      for(auto i:vs[i].edges){
        int next=es[i].nextvertex(now);
        if(next==pre)continue;
        opes.push_back({next,now,len+es[i].length,cost+es[i].cost});
      }
      opes.pop_front();
    }
  }
};
int main(void){
  int n;
  cin>>n;
  graph<ll> G(n);
  int m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G.bind_bi(a,b,1,1);
  }
  G.DFS(0,0,0,{},-1);
  cout<<G.ans<<endl;
  return 0;
}

//clang++ -g -fsanitize=address -fno-omit-frame-pointer 1.cpp -o test.exe

//<<std::setprecision(30)

//重複削除
 /* std::sort(vec.begin(), vec.end());
 
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());*/

  //ペアの全探索
  /*do{
		int s=0;
		for(int i=0;i<n/2;i++)s+=v[i]^v[i+n/2];
		r=max(s,r);
		reverse(v.begin()+n/2,v.end());
	}while(next_permutation(v.begin(),v.end()));*/


Compiler output:
a.cc:49:33: error: expected class-name before '{' token
   49 | class Uniedge : public Baseedge {
      |                                 ^
a.cc:61:32: error: expected class-name before '{' token
   61 | class Biedge : public Baseedge {
      |                                ^
a.cc: In member function 'void graph<T>::BFS(int)':
a.cc:133:18: error: invalid declarator before 'opes'
  133 |     queue<opera> opes;
      |                  ^~~~
a.cc:134:5: error: 'opes' was not declared in this scope; did you mean 'es'?
  134 |     opes.push_back({ini,-1,0,0});
      |     ^~~~
      |     es
a.cc:140:21: error: 'i' was not declared in this scope
  140 |       for(auto i:vs[i].edges){
      |                     ^
a.cc: In instantiation of 'class Biedge<long long int>':
a.cc:107:27:   required from 'void graph<T>::bind_bi(int, int, T, T) [with T = long long int]'
  107 |     Baseedge<T> newedge = new Biedge<T>(v1,v2,len,cost,num);
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:158:14:   required from here
  158 |     G.bind_bi(a,b,1,1);
      |     ~~~~~~~~~^~~~~~~~~
a.cc:67:9: error: 'int Biedge<T>::nextvertex(int) [with T = long long int]' marked 'override', but does not override
   67 |     int nextvertex(int from) override {
      |         ^~~~~~~~~~
a.cc: In instantiation of 'void graph<T>::bind_bi(int, int, T, T) [with T = long long int]':
a.cc:158:14:   required from here
  158 |     G.bind_bi(a,b,1,1);
      |     ~~~~~~~~~^~~~~~~~~
a.cc:107:17: error: cannot allocate an object of abstract type 'Baseedge<long long int>'
  107 |     Baseedge<T> newedge = new Biedge<T>(v1,v2,len,cost,num);
      |                 ^~~~~~~
a.cc:32:7: note:   because the following virtual functions are pure within 'Baseedge<long long int>':
   32 | class Baseedge {
      |       ^~~~~~~~
a.cc:46:17: note:     'int Baseedge<T>::nextvertex(int) [with T = long long int]'
   46 |     virtual int nextvertex(int from)=0;
      |                 ^~~~~~~~~~
a.cc:107:17: error: cannot declare variable 'newedge' to be of abstract type 'Baseedge<long long int>'
  107 |     Baseedge<T> newedge = new Biedge<T>(v1,v2,len,cost,num);
      |                 ^~~~~~~