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 = 1001001001;
const int di = {-1, 0, 1, 0};
const int dj = {0, -1, 0, 1};

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(si,h)rep(sj,w){
            if(s[si][sj]=='#') continue;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            //配列に初期値 vector<型>(要素数,初期値)
            queue<P> q;
            auto update[&](int i, int j, int x){
                if(dist[i][j]!= INF) return;
                dist[i][j] = x;
                q.emplace(i,j); //push(P(i,j))
            
            };
            update(si,sj,0);
            while(!q.empty()){ //qが空になるまで
                int i = q.front().first;
                int j = q.front().second;
                q.pop(); //ないとずっと回り続ける
                rep(dir,4){
                    int ni = i + di[dir];
                    int nj = j + dj[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(j,w){
                if(dist[i][j] == INF) continue;
                ans = max(ans, dist[i][j]);

            }
        }
        cout << ans << endl;
        return 0;
    }
   


Compiler output:
a.cc:7:11: error: scalar object 'di' requires one element in initializer
    7 | const int di = {-1, 0, 1, 0};
      |           ^~
a.cc:8:11: error: scalar object 'dj' requires one element in initializer
    8 | const int dj = {0, -1, 0, 1};
      |           ^~
a.cc: In function 'int main()':
a.cc:21:26: error: expected primary-expression before ']' token
   21 |             auto update[&](int i, int j, int x){
      |                          ^
a.cc:22:17: error: expected primary-expression before 'if'
   22 |                 if(dist[i][j]!= INF) return;
      |                 ^~
a.cc:22:17: error: expected '}' before 'if'
a.cc:21:48: note: to match this '{'
   21 |             auto update[&](int i, int j, int x){
      |                                                ^
a.cc:23:22: error: 'i' was not declared in this scope
   23 |                 dist[i][j] = x;
      |                      ^
a.cc:23:25: error: 'j' was not declared in this scope
   23 |                 dist[i][j] = x;
      |                         ^
a.cc:23:30: error: 'x' was not declared in this scope
   23 |                 dist[i][j] = x;
      |                              ^
a.cc:27:20: error: 'si' was not declared in this scope; did you mean 's'?
   27 |             update(si,sj,0);
      |                    ^~
      |                    s
a.cc:27:23: error: 'sj' was not declared in this scope; did you mean 's'?
   27 |             update(si,sj,0);
      |                       ^~
      |                       s
a.cc:27:13: error: 'update' was not declared in this scope
   27 |             update(si,sj,0);
      |             ^~~~~~
a.cc:28:20: error: 'q' was not declared in this scope
   28 |             while(!q.empty()){ //qが空になるまで
      |                    ^
a.cc:37:36: error: 'dist' was not declared in this scope
   37 |                     update(ni, nj, dist[i][j]+1);
      |                                    ^~~~
a.cc:41:20: error: 'dist' was not declared in this scope
   41 |                 if(dist[i][j] == INF) continue;
      |                    ^~~~
a.cc:42:32: error: 'dist' was not declared in this scope
   42 |                 ans = max(ans, dist[i][j]);
      |                                ^~~~
a.cc: At global scope:
a.cc:46:9: error: 'cout' does not name a type
   46 |         cout << ans << endl;
      |         ^~~~
a.cc:47:9: error: expected unqualified-id before 'return'
   47 |         return 0;
      |         ^~~~~~
a.cc:48:5: error: expected declaration before '}' token
   48 |     }
      |     ^