Language: C++

include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> f(h);
  rep(i,h) cin >> f[i];
  rep(si,h)rep(sj,w) {
    if (f[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x){
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j));
    };
    update(si,sj,0);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      rep(dir,4) {
        int ni = i + dx[dir], nj = j + dy[dir];
        if (ni<0||ni>=h||nj<0||nj>=w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni,nj,dist[i][j]+1);
      }
    }
    rep(i,h)rep(i,w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans,dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair<int, int> P;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:12:3: error: 'cin' was not declared in this scope
   12 |   cin >> h >> w;
      |   ^~~
a.cc:13:3: error: 'vector' was not declared in this scope
   13 |   vector<string> f(h);
      |   ^~~~~~
a.cc:13:10: error: 'string' was not declared in this scope
   13 |   vector<string> f(h);
      |          ^~~~~~
a.cc:13:18: error: 'f' was not declared in this scope
   13 |   vector<string> f(h);
      |                  ^
a.cc:17:19: error: expected primary-expression before 'int'
   17 |     vector<vector<int>> dist(h, vector<int>(w, INF));
      |                   ^~~
a.cc:18:5: error: 'queue' was not declared in this scope
   18 |     queue<P> q;
      |     ^~~~~
a.cc:18:11: error: 'P' was not declared in this scope
   18 |     queue<P> q;
      |           ^
a.cc:18:14: error: 'q' was not declared in this scope
   18 |     queue<P> q;
      |              ^
a.cc: In lambda function:
a.cc:20:11: error: 'dist' was not declared in this scope
   20 |       if (dist[i][j] != INF) return;
      |           ^~~~
a.cc:20:25: error: 'INF' was not declared in this scope
   20 |       if (dist[i][j] != INF) return;
      |                         ^~~
a.cc:21:7: error: 'dist' was not declared in this scope
   21 |       dist[i][j] = x;
      |       ^~~~
a.cc: In function 'int main()':
a.cc:31:13: error: 's' was not declared in this scope
   31 |         if (s[ni][nj] == '#') continue;
      |             ^
a.cc:32:22: error: 'dist' was not declared in this scope
   32 |         update(ni,nj,dist[i][j]+1);
      |                      ^~~~
a.cc:36:11: error: 'dist' was not declared in this scope
   36 |       if (dist[i][j] == INF) continue;
      |           ^~~~
a.cc:36:19: error: 'j' was not declared in this scope
   36 |       if (dist[i][j] == INF) continue;
      |                   ^
a.cc:36:25: error: 'INF' was not declared in this scope
   36 |       if (dist[i][j] == INF) continue;
      |                         ^~~
a.cc:37:7: error: 'ans' was not declared in this scope
   37 |       ans = max(ans,dist[i][j]);
      |       ^~~
a.cc:37:21: error: 'dist' was not declared in this scope
   37 |       ans = max(ans,dist[i][j]);
      |                     ^~~~
a.cc:37:29: error: 'j' was not declared in this scope
   37 |       ans = max(ans,dist[i][j]);
      |                             ^
a.cc:37:13: error: 'max' was not declared in this scope
   37 |       ans = max(ans,dist[i][j]);
      |             ^~~
a.cc:40:3: error: 'cout' was not declared in this scope
   40 |   cout << ans << endl;
      |   ^~~~
a.cc:40:11: error: 'ans' was not declared in this scope
   40 |   cout << ans << endl;
      |           ^~~
a.cc:40:18: error: 'endl' was not declared in this scope
   40 |   cout << ans << endl;
      |                  ^~~~