Language: C++

#include <bits/stdc++.h>
using namespace std;

void swap2(vector<int> A, vector<int> B,int x, int y) {
  int ax = A.at(x);
  int ay = A.at(y);
  int bx = B.at(x);
  int by = B.at(y);
  vector<int> nA = A;
  vector<int> nB = B;
  nA.at(x) = by;
  nA.at(y) = bx;
  nB.at(x) = ay;
  nB.at(y) = bx;
}


bool check(vector<int> vec) {
  bool ok = true;
  for (int i = 0;i < vec.size()-1;i++) {
    if (vec.at(i) > vec.at(i+1)) ok = false;
  }
  return ok;
}

  



int bfs(vector<int> A, vector<int> B) {
  pair<vector<int>, vector<int>> p;
  p = make_pair(A,B);
  map<pair<vector<int>, vector<int>>, int> dist;
  queue<vector<int>> aq;   
  queue<vector<int>> bq;
  int cnt = 0;
  
  //初期値
  dist[p] = 1;   //ごめん、こうするから後で１引いて
  aq.push_back(A);
  bq.push_back(B);
  
  while(!aq.empty()) {
    vector<int> a = aq.front();
    vector<int> b = bq.front();
    aq.pop();
    bq.pop();
    
    for (int i = 0;i < N;i++) {
      for (int j = 0; j < N;j++) {
        swap2(a,b,i,j);
        if (dist[make_pair(nA,nB)] != 0) continue;
        if (check(nA)) {
          ok = ture;
          cnt = dist[make_pair(a,b)] + 1;
          queue<vector<int>> nq;
          aq = nq;
        dist[make_pair(nA,nB)] = dist[make_pair(a,b)] + 1;
        aq.push_back(nA);
        bq.push_back(nB);
        }
      }
    }
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i<N;i++) {
    cin >> A.at(i);
  }
  for (int i = 0;i <N;i++) {
    cin >> B.at(i);
  }
  bfs(A,B);
  cout << cnt-1 << endl;
}
  



Compiler output:
a.cc: In function 'int bfs(std::vector<int>, std::vector<int>)':
a.cc:40:6: error: 'class std::queue<std::vector<int> >' has no member named 'push_back'
   40 |   aq.push_back(A);
      |      ^~~~~~~~~
a.cc:41:6: error: 'class std::queue<std::vector<int> >' has no member named 'push_back'
   41 |   bq.push_back(B);
      |      ^~~~~~~~~
a.cc:49:24: error: 'N' was not declared in this scope
   49 |     for (int i = 0;i < N;i++) {
      |                        ^
a.cc:52:28: error: 'nA' was not declared in this scope; did you mean 'A'?
   52 |         if (dist[make_pair(nA,nB)] != 0) continue;
      |                            ^~
      |                            A
a.cc:52:31: error: 'nB' was not declared in this scope; did you mean 'B'?
   52 |         if (dist[make_pair(nA,nB)] != 0) continue;
      |                               ^~
      |                               B
a.cc:53:19: error: 'nA' was not declared in this scope; did you mean 'A'?
   53 |         if (check(nA)) {
      |                   ^~
      |                   A
a.cc:54:11: error: 'ok' was not declared in this scope
   54 |           ok = ture;
      |           ^~
a.cc:54:16: error: 'ture' was not declared in this scope
   54 |           ok = ture;
      |                ^~~~
a.cc:58:27: error: 'nB' was not declared in this scope; did you mean 'nq'?
   58 |         dist[make_pair(nA,nB)] = dist[make_pair(a,b)] + 1;
      |                           ^~
      |                           nq
a.cc:59:12: error: 'class std::queue<std::vector<int> >' has no member named 'push_back'
   59 |         aq.push_back(nA);
      |            ^~~~~~~~~
a.cc:60:12: error: 'class std::queue<std::vector<int> >' has no member named 'push_back'
   60 |         bq.push_back(nB);
      |            ^~~~~~~~~
a.cc:65:1: warning: no return statement in function returning non-void [-Wreturn-type]
   65 | }
      | ^
a.cc: In function 'int main()':
a.cc:79:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   79 |   cout << cnt-1 << endl;
      |           ^~~
      |           int