Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int N,M;
Graph Gini,G;

int main() {
  cin >>N >>M;
  Gini.assign(N, vector<int>());
  G.assign(N, vector<int>());
  rep(i, M){
    int u,v; cin >>u >>v; u--; v--;
    Gini[u].push_back(v);
  }
  // G = (V, E) を構築する。
  // 任意の (u, v) <= E について、
  // Giniにおいて u から 3 つ辿れば v に行ける。但し u != v。
  vector<vector<bool>> seen;
  for (int i=0; i<N; i++){
    // ノード i から3つ辿って行ける所をGに突っ込む
    seen.assign(N, vector<bool>(4, false));
    seen[i][0] = true;
    queue<pair<int,int>> que;
    que.push({0, i});
    while (!que.empty()){
      auto p = que.front(); que.pop();
      int distance = p.first;
      int v = p.second;
      if (distance == 3){
        if (i != v){
          G[i].push_back(v);
        }
      }else{
        for (int nv : Gini[v]){
          if (seen[nv][distance+1]) continue;
          seen[nv][distance+1] = true;
          que.push({distance+1, nv});
        }
      }
    }
  }
  // GについてBFSを行ってsからtへの最短距離を求める
  int s,t; cin >>s >>t; s--; t--;
  vector<bool> seen(N, false);
  vector<int> dist(N, -1);
  dist[s] = 0;
  queue<int> que;
  que.push(s);
  while (!que.empty()){
    int v = que.front(); que.pop();
    for (int nv : G[v]){
      if (seen[nv]) continue;
      seen[nv] = true;
      dist[nv] = dist[v] + 1;
      que.push(nv);
    }
  }
  int res = dist[t];
  cout <<res <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:16: error: conflicting declaration 'std::vector<bool> seen'
   70 |   vector<bool> seen(N, false);
      |                ^~~~
a.cc:44:24: note: previous declaration as 'std::vector<std::vector<bool> > seen'
   44 |   vector<vector<bool>> seen;
      |                        ^~~~
a.cc:78:19: error: could not convert 'seen.std::vector<std::vector<bool> >::operator[](((std::vector<std::vector<bool> >::size_type)nv))' from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type' {aka 'std::vector<bool>'} to 'bool'
   78 |       if (seen[nv]) continue;
      |                   ^
      |                   |
      |                   __gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type {aka std::vector<bool>}
a.cc:79:18: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type' {aka 'std::vector<bool>'} and 'bool')
   79 |       seen[nv] = true;
      |                  ^~~~
In file included from /usr/include/c++/14/vector:67,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_bvector.h:894:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>]'
  894 |       operator=(const vector& __x)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:894:31: note:   no known conversion for argument 1 from 'bool' to 'const std::vector<bool>&'
  894 |       operator=(const vector& __x)
      |                 ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_bvector.h:926:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::vector<bool, _Alloc>&&) [with _Alloc = std::allocator<bool>]'
  926 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:926:26: note:   no known conversion for argument 1 from 'bool' to 'std::vector<bool>&&'
  926 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_bvector.h:952:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::initializer_list<bool>) [with _Alloc = std::allocator<bool>]'
  952 |       operator=(initializer_list<bool> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:952:40: note:   no known conversion for argument 1 from 'bool' to 'std::initializer_list<bool>'
  952 |       operator=(initializer_list<bool> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~