Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
int a[10];//基础数组
int b[10];//存目标数组1
int c[10];//存目标数组2 
using namespace std;
int main()
{
  
    int n,t2 = 0,t1 = 0;
    scanf("%d",&n);
  

    for(int i=0; i<n; i++)
        a[i] = i+1;  //以0开头的存的是 这个最基本的哪一个数字 

        for(int i=0; i<n; ++i)
            scanf("%d",&b[i]);//每一个i表示一位数字
		 for(int i=0; i<n; ++i)
            scanf("%d",&c[i]);//每一个i表示一位数字
		

    do{
        t1++;
        int flag = 0;
        for(int i=0; i<n; ++i){
            if(a[i]!=b[i]){ //对比基本数字和存储的
			//如果不相等就是1 
			//退出循环开始演算基础的 继续拍
			//直到找到相等的 也就是位置 记录位置是第t个 
                flag = 1;
                break;
            }
        }
        if(!flag)
            break;
    }while(next_permutation(a[0],a[0]+n));

    for(int i=0; i<n; i++)
        a[i] = i+1; 

    do{
        t2++;
        int flag = 0;
        for(int i=0; i<n; ++i){
            if(a[i]!=c[i]){
                flag = 1;
                break;
            }
        }
        if(!flag){
            break;
        }
    }while(next_permutation(a[0],a[0]+n));

    printf("%d",abs(t1-t2));
    return 0;
}


Compiler output:
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:28:   required from here
   41 |     }while(next_permutation(a[0],a[0]+n));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2912:54: error: no matching function for call to '__iterator_category(int&)'
 2912 |                              std::__iterator_category(__first));
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66,
                 from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/14/bits/stl_algo.h:2912:33:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2912 |                              std::__iterator_category(__first));
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:28:   required from here
   41 |     }while(next_permutation(a[0],a[0]+n));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:28:   required from here
   41 |     }while(next_permutation(a[0],a[0]+n));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2918:54: error: no matching function for call to '__iterator_category(int&)'
 2918 |                              std::__iterator_category(__first));
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/14/bits/stl_algo.h:2918:33:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2918 |                              std::__iterator_category(__first));
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:28:   required from here
   41 |     }while(next_permutation(a[0],a[0]+n));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]':
/usr/include/c++/14/bits/stl_algo.h:2905:14:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2905 |           if (__comp(__i, __ii))
      |               ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:28:   required from here
   41 |     }while(next_permutation(a[0],a[0]+n));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:16: error: invalid type argument of unary '*' (have 'int')
   45 |       { return *__it1 < *__it2; }
      |                ^~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:25: error: invalid type argument of unary '*' (have 'int')
   45 |       { return *__it1 < *__it2; }
      |                         ^~~~~~
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int; _ForwardIterator2 = int]':
/usr/include/c++/14/bits/stl_algo.h:2910:22:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2910 |               std::iter_swap(__i, __j);
      |               ~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:28:   required from here
   41 |     }while(next_permutation(a[0],a[0]+n));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:185:12: error: invalid type argument of unary '*' (have 'int')
  185 |       swap(*__a, *__b);
      |            ^~~~
/usr/include/c++/14/bits/stl_algobase.h:185:18: error: invalid type argument of unary '*' (have 'int')
  185 |       swap(*__a, *__b);
      |                  ^~~~