func_code_string: #include <iostream>   #include <cstdio>   #include <cmath>   #include <cstring>   #include <vector>   #include <map>      #include <set>   #include <cmath>   #include <queue>   #include <algorithm>   #include <numeric>   using namespace std;   typedef long long ll;   const int N=1e6+5;   const int M=1e3+5;   const int mod=1e9+7;   int n,m;   int T,a[N];   std::vector<int> ans;   int rns;   bool cal(vector<int> v,std::vector<int> v1){       for(int i=0;i<n*2;i++){           if(v[i]!=v1[i])return 0;       }       return 1;   }   map<std::vector<int>,int>mp;   void bfs(){       queue<vector<int> >q;       std::vector<int>G;       for(int i=1;i<=n*2;i++)G.push_back(i);           rns=-1;       q.push(G);       mp[G]=0;       while(!q.empty()){           std::vector<int> now=q.front();           q.pop();           if(cal(now,ans)==1){               rns=mp[now];               return ;           }           std::vector<int> v1=now;           for(int i=0;i+1<n*2;i+=2){               swap(v1[i],v1[i+1]);           }           std::vector<int> v2=now;           for(int i=0;i+n<n*2;i++){               swap(v2[i],v2[i+n]);           }           if(!mp.count(v1)){               q.push(v1);               mp[v1]=mp[now]+1;           }           if(!mp.count(v2)){               q.push(v2);               mp[v2]=mp[now]+1;           }       }               }   int main() {       scanf( %d ,&n);       for(int i=1;i<=n*2;i++)scanf( %d ,&a[i]),ans.push_back(a[i]);       bfs();   cout<<rns<<endl;                                     }