Language: C++

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const vector<vector<int>> dir4 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> hen(h + 2, vector<bool>(w + 2));
    for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++){
        char tmp; cin >> tmp; hen[i][j] = tmp == '.';
    }
    int res = 0;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            for(int k = 1; k <= h; k++){
                for(int t = 1; t <= w; t++){

                    if(!hen[i][j] || !hen[k][t])continue;
                    vector<vector<int>> dist(h + 2, vector<int>(w + 2, -1));
                    queue<pair<int,int>> que;
                    dist[i][j] = 0;


                    que.push({i,j});
                    while(true) {
                        auto cur = que.front();
                        que.pop();
                        if(cur.first == k && cur.second == t){
                            res = max(res, dist[cur.first][cur.second]);
                            break;
                        }

                        for(int i = 0; i < 4; i++){
                            int y = cur.first + dir[i][0], x = cur.second + ddir[i][1];
                            if(!hen[y][x] || dist[y][x] != -1)continue;
                            dist[y][x] = dist[cur.first][cur.second] + 1;
                            que.push({y,x});
                        }
                    }


                }
            }
        }
    }


    cout << res << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:49: error: 'dir' was not declared in this scope; did you mean 'div'?
   39 |                             int y = cur.first + dir[i][0], x = cur.second + ddir[i][1];
      |                                                 ^~~
      |                                                 div
a.cc:40:40: error: 'x' was not declared in this scope
   40 |                             if(!hen[y][x] || dist[y][x] != -1)continue;
      |                                        ^
a.cc:41:37: error: 'x' was not declared in this scope
   41 |                             dist[y][x] = dist[cur.first][cur.second] + 1;
      |                                     ^
a.cc:42:37: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   42 |                             que.push({y,x});
      |                             ~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<std::pair<int, int> >::value_type&' {aka 'const std::pair<int, int>&'}
  283 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  288 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~