Language: C++

    typedef std::vector<std::vector<int>> State;
    const int N = 3;

    State int_to_state(int c){
      std::vector<std::vector<int>> state(N, std::vector<int>(N));
      FOR(i, N) {
        FOR(j, N) {
          int r = c%10;
          c = c/10;
          state[i][j] = r;
        }
      }
      return state;
    }
    int state_to_int(State state) {
      int c = 0;
      int p = 1;
      FOR(i, N) {
        FOR(j, N) {
          c += state[i][j] * p;
          p *= 10;
        }
      }
      return c;
    }


    void show(std::vector<std::vector<int>> state){
      FOR(i, N) {
        FOR(j, N) {
          std::cout << state[i][j] << " ";
        }
        std::cout << std::endl;
      }
    }

    bool is_solved(const State& state) {
      int N = state.size();

      FOR(i, N) {
        FOR(j, N) {
          if(state[i][j] != (1 + 3*i + j)) return false;
        }
      }
      return true;
    }

    std::vector<State> next_states_of(State state){
      std::vector<State> res;
      auto ns = state; std::swap(ns[0][0], ns[0][1]); res.push_back(ns);
      ns = state; std::swap(ns[0][1], ns[0][2]); res.push_back(ns);
      ns = state; std::swap(ns[1][0], ns[1][1]); res.push_back(ns);
      ns = state; std::swap(ns[1][1], ns[1][2]); res.push_back(ns);
      ns = state; std::swap(ns[2][0], ns[2][1]); res.push_back(ns);
      ns = state; std::swap(ns[2][1], ns[2][2]); res.push_back(ns);
      ns = state; std::swap(ns[0][0], ns[1][0]); res.push_back(ns);
      ns = state; std::swap(ns[1][0], ns[2][0]); res.push_back(ns);
      ns = state; std::swap(ns[0][1], ns[1][1]); res.push_back(ns);
      ns = state; std::swap(ns[1][1], ns[2][1]); res.push_back(ns);
      ns = state; std::swap(ns[0][2], ns[1][2]); res.push_back(ns);
      ns = state; std::swap(ns[1][2], ns[2][2]); res.push_back(ns);
//      std::cout << res.size() <<std::endl;
      return res;
    }

    int solve_puzzle(State state){

      std::priority_queue<
        std::pair<int, int>,
        std::vector<std::pair<int, int>>,
        std::greater<std::pair<int, int>>
      > q;
      std::unordered_map<int, int> h;

      q.push(std::make_pair(0, state_to_int(state)));

      for(;not q.empty();){
        auto d_s = q.top(); q.pop();
        int d = d_s.first;
        int st_int = d_s.second;
        State state = int_to_state(d_s.second);
//        show(state);

        if(st_int == 987654321){
//          std::cout << "z"<< std::endl;
          return d;
        }

        if(h.find(st_int) == h.end()){
          h[st_int] = d;
          std::vector<State> next_states = next_states_of(state);
          for(auto ns : next_states){
            q.push(std::make_pair(d+1, state_to_int(ns)));
          }
        }
      }
      return -1;
    }
#include <iostream>
#include <vector>
#include <utility>
#include <utility>
#include <algorithm>
#include <queue>
#include <numeric>
#include <unordered_map>

    int main(){
      const int N = 3;
      std::vector<std::vector<int>> state(N, std::vector<int>(N));

      FOR(i, N){
        FOR(j, N){
          GET(int, x);
          if(x==0) x=9;
          state[i][j] = x;
        }
      }
//      show(state);
//      int c = state_to_int(state);
//      std::cout << c << std::endl;
//      std::cout << "?" <<std::endl;
//      State s2 = int_to_state(c);
//      std::cout << "!" <<std::endl;
//
//      show(s2);
//      int min_steps = rec_min_steps_
      std::cout << solve_puzzle(state) << std::endl;
      return 0;
    }

Compiler output:
a.cc:1:18: error: 'vector' in namespace 'std' does not name a template type
    1 |     typedef std::vector<std::vector<int>> State;
      |                  ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 |     typedef std::vector<std::vector<int>> State;
a.cc:4:5: error: 'State' does not name a type
    4 |     State int_to_state(int c){
      |     ^~~~~
a.cc:15:22: error: 'State' was not declared in this scope
   15 |     int state_to_int(State state) {
      |                      ^~~~~
a.cc:28:10: error: variable or field 'show' declared void
   28 |     void show(std::vector<std::vector<int>> state){
      |          ^~~~
a.cc:28:20: error: 'vector' is not a member of 'std'
   28 |     void show(std::vector<std::vector<int>> state){
      |                    ^~~~~~
a.cc:28:20: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:28:32: error: 'vector' is not a member of 'std'
   28 |     void show(std::vector<std::vector<int>> state){
      |                                ^~~~~~
a.cc:28:32: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:28:39: error: expected primary-expression before 'int'
   28 |     void show(std::vector<std::vector<int>> state){
      |                                       ^~~
a.cc:37:26: error: 'State' does not name a type
   37 |     bool is_solved(const State& state) {
      |                          ^~~~~
a.cc: In function 'bool is_solved(const int&)':
a.cc:38:21: error: request for member 'size' in 'state', which is of non-class type 'const int'
   38 |       int N = state.size();
      |                     ^~~~
a.cc:40:11: error: 'i' was not declared in this scope
   40 |       FOR(i, N) {
      |           ^
a.cc:40:7: error: 'FOR' was not declared in this scope
   40 |       FOR(i, N) {
      |       ^~~
a.cc: At global scope:
a.cc:48:10: error: 'vector' in namespace 'std' does not name a template type
   48 |     std::vector<State> next_states_of(State state){
      |          ^~~~~~
a.cc:48:5: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
   48 |     std::vector<State> next_states_of(State state){
      |     ^~~
a.cc:66:22: error: 'State' was not declared in this scope
   66 |     int solve_puzzle(State state){
      |                      ^~~~~
a.cc: In function 'int main()':
a.cc:112:11: error: 'i' was not declared in this scope
  112 |       FOR(i, N){
      |           ^
a.cc:112:7: error: 'FOR' was not declared in this scope
  112 |       FOR(i, N){
      |       ^~~
a.cc:128:32: error: 'solve_puzzle' cannot be used as a function
  128 |       std::cout << solve_puzzle(state) << std::endl;
      |                    ~~~~~~~~~~~~^~~~~~~