Language: C++

#include <set>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N, T;
    
    cin >> N;
    
    vector<int> A(N);
    
    for(int i = 0; i < N; i++) { cin >> T; A[i] = T; }
    
    vector<char> B = A; sort(B.begin(), B.end());
    
    set<vector<char>, bool> dat; dat.insert(A);
    
    queue<vector<char> > que; que.push(A);
    
    queue<char> que2; que2.push(0);
    
    if(A == B) { cout << 0 << endl; goto Exit; }
    
    while(que.size())
    {
        vector<char> v1 = que.front(); que.pop();
        
        int dist = que2.front(); que2.pop();
        
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                vector<char> v2 = v1;
                
                swap(v2[i], v2[j]);
                
                if(v2 == B) { cout <<  dist + 1 << endl; goto Exit; }
                
                if(dat.find(v2) == dat.end())
                {
                    dat.insert(v2);
                    
                    que.push(v2);
                    
                    que2.push(dist + 1);
                }
            }
        }
    }
    
    Exit:;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:22: error: conversion from 'vector<int>' to non-scalar type 'vector<char>' requested
   19 |     vector<char> B = A; sort(B.begin(), B.end());
      |                      ^
a.cc:21:44: error: no matching function for call to 'std::set<std::vector<char>, bool>::insert(std::vector<int>&)'
   21 |     set<vector<char>, bool> dat; dat.insert(A);
      |                                  ~~~~~~~~~~^~~
In file included from /usr/include/c++/14/set:63,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >]'
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::vector<char> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::rebind<std::vector<char> >; typename _Alloc::value_type = std::vector<char>; value_type = std::vector<char>]'
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:511:32: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::set<std::vector<char>, bool>::value_type&' {aka 'const std::vector<char>&'}
  511 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:520:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::vector<char> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::rebind<std::vector<char> >; typename _Alloc::value_type = std::vector<char>; value_type = std::vector<char>]'
  520 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:520:27: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::set<std::vector<char>, bool>::value_type&&' {aka 'std::vector<char>&&'}
  520 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:548:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, const value_type&) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >; iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; const_iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; value_type = std::vector<char>]'
  548 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:548:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:553:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, value_type&&) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >; iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; const_iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; value_type = std::vector<char>]'
  553 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:553:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:580:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >]'
  580 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:580:43: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<std::vector<char> >'
  580 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:600:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::insert_return_type std::set<_Key, _Compare, _Alloc>::insert(node_type&&) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >; insert_return_type = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::insert_return_type; node_type = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::node_type]'
  600 |       insert(node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:600:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::set<std::vector<char>, bool>::node_type&&' {aka 'std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::node_type&&'}
  600 |       insert(node_type&& __nh)
      |              ~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_set.h:605:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, node_type&&) [with _Key = std::vector<char>; _Compare = bool; _Alloc = std::allocator<std::vector<char> >; iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; const_iterator = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::const_iterator; node_type = std::_Rb_tree<std::vector<char>, std::vector<char>, std::_Identity<std::vector<char> >, bool, std::allocator<std::vector<char> > >::node_type]'
  605 |       insert(const_iterator __hint, node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:605:7: note:   candidate expects 2 arguments, 1 provided
a.cc:23:39: error: no matching function for call to 'std::queue<std::vector<char> >::push(std::vector<int>&)'
   23 |     queue<vector<char> > que; que.push(A);
      |                               ~~~~~~~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::vector<char>; _Sequence = std::deque<std::vector<char>, std::allocator<std::vector<char> > >; value_type = std::vector<char>]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::queue<std::vector<char> >::value_type&' {aka 'const std::vector<char>&'}
  283 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::vector<char>; _Sequence = std::deque<std::vector<char>, std::allocator<std::vector<char> > >; value_type = std::vector<char>]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:25: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::queue<std::vector<char> >::value_type&&' {aka 'std::vector<char>&&'}
  288 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc:27:10: error: no match for 'operator==' (operand types are 'std::vector<int>' and 'std::vector<char>')
   27 |     if(A == B) { cout << 0 << endl; goto Exit; }
      |        ~ ^~ ~
      |        |    |
      |        |    vector<char>
      |        vector<int>
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/set:62:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
a.cc:27:13: note:   'std::vector<int>' is not derived from 'const std::pair<_T1, _T2>'
   27