Language: C++

#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space:
  string path;

  bool operator < (const puzzle &p) const {
    for(int i=0; i<N2; i++){
      if(f[i] == p.f[i]) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1);
static const char dir[4] = {'u', 'l', 'd','r'};

bool isTarget(Puzzle p) {
  for(int i=0; i<N2; i++)
    if(p.f[o] != (i+1)) return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u, v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while(!Q.empty()){
    u = Q.front(); Q.pop();
    if(isTarget(u)) return u.path;
    int sx = u.space/N;
    int sy u.space%N;
    for(int r=0; r<4; r++){
      int tx = sx+dx[r];
      int ty = sy+dy[r];
      if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
      v=u;
      swap(v.f[u.space], v.f[tx*N+ty]);
      v.space = tx*N+ty;
      if(!V[v]){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }
  return "usdolvable";
}

int main(){
  Puzzle in;

  for(int i=0; i<N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in .space = i;
    }
  }

  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}

Compiler output:
a.cc:13:10: error: expected primary-expression before 'path'
   13 |   string path;
      |          ^~~~
a.cc:13:3: error: expected ';' at end of member declaration
   13 |   string path;
      |   ^~~~~~
      |         ;
a.cc:13:10: error: 'path' does not name a type
   13 |   string path;
      |          ^~~~
a.cc:15:26: error: 'puzzle' does not name a type; did you mean 'Puzzle'?
   15 |   bool operator < (const puzzle &p) const {
      |                          ^~~~~~
      |                          Puzzle
a.cc: In member function 'bool Puzzle::operator<(const int&) const':
a.cc:17:20: error: request for member 'f' in 'p', which is of non-class type 'const int'
   17 |       if(f[i] == p.f[i]) continue;
      |                    ^
a.cc:18:23: error: request for member 'f' in 'p', which is of non-class type 'const int'
   18 |       return f[i] > p.f[i];
      |                       ^
a.cc: At global scope:
a.cc:25:38: error: expected '}' before ')' token
   25 | static const int dy[4] = {0, -1, 0, 1);
      |                          ~           ^
a.cc:25:38: error: expected ',' or ';' before ')' token
a.cc: In function 'bool isTarget(Puzzle)':
a.cc:30:12: error: 'o' was not declared in this scope
   30 |     if(p.f[o] != (i+1)) return false;
      |            ^
a.cc: In function 'std::string bfs(Puzzle)':
a.cc:38:5: error: 'struct Puzzle' has no member named 'path'
   38 |   s.path = "";
      |     ^~~~
a.cc:44:30: error: 'struct Puzzle' has no member named 'path'
   44 |     if(isTarget(u)) return u.path;
      |                              ^~~~
a.cc:46:12: error: expected initializer before 'u'
   46 |     int sy u.space%N;
      |            ^
a.cc:49:16: error: 'sy' was not declared in this scope; did you mean 'ty'?
   49 |       int ty = sy+dy[r];
      |                ^~
      |                ty
a.cc:56:11: error: 'struct Puzzle' has no member named 'path'
   56 |         v.path += dir[r];
      |           ^~~~
In file included from /usr/include/c++/14/string:49,
                 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_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Puzzle]':
/usr/include/c++/14/bits/stl_map.h:511:32:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = Puzzle; _Tp = bool; _Compare = std::less<Puzzle>; _Alloc = std::allocator<std::pair<const Puzzle, bool> >; mapped_type = bool; key_type = Puzzle]'
  511 |         if (__i == end() || key_comp()(__k, (*__i).first))
      |                             ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:40:6:   required from here
   40 |   V[s] = true;
      |      ^
/usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const Puzzle' and 'const Puzzle')
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
a.cc:15:8: note: candidate: 'bool Puzzle::operator<(const int&) const'
   15 |   bool operator < (const puzzle &p) const {
      |        ^~~~~~~~
a.cc:15:34: note:   no known conversion for argument 1 from 'const Puzzle' to 'const int&'
   15 |   bool operator < (const puzzle &p) const {
      |                    ~~~~~~~~~~~~~~^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const Puzzle' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const Puzzle' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const Puzzle' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const Puzzle' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~