Language: C++

#include <iostream>
#include <unordered_map>
#include <queue>
#include <utility>
#include <functional>

int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
    int x;
    int step;
};
void fx(int y){
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < 4;j++){
            a[i][j] = y % 8;
            y = (int)(y / 8);
            if(a[i][j] == 0){
                stx = j , sty = i; 
            }
        }
    }
}
bool f(int k){
    if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
        return false;
    }
    nx = 0;
    int tmp = 1;
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < 4;j++){
            if(i == sty && j == stx){
                nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
            }else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
                nx += 0;
            }else{
                nx += tmp * a[i][j];
            }
            tmp *= 8;
        }
    }
    return true;
}
int main(){
    st.insert(std::make_pair<int , int>(16434824 , 0));
    node nod;
    nod.x = 16434824 , nod.step = 0;
    std::queue <node> que;
    que.push(nod);
    while(!que.empty()){
        nod = que.front();
        que.pop();
        fx(nod.x);
        for(int i = 0;i < 4;i++){
            if(f(i)){
                if(st.find(nx) == st.end()){
                    st.insert(std::make_pair<int , int>(nx , nod.step + 1));
                    node nod1;
                    nod1.x = nx , nod1.step = nod.step + 1;
                    que.push(nod1);
                }
            }
        }
    }
    while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
        int mark = 0 , tmp = 1;
        for(int i = 0;i < 2;i++){
            for(int j = 0;j < 4;j++){
                mark += tmp * a[i][j];
                tmp *= 8;
            }
        }
        std::cout << st.at(mark) << "\n";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   58 |                     st.insert(std::make_pair<int , int>(nx , nod.step + 1));
      |                                                         ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 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_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~