Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
const int di[]={0,-1,0,1};
const int dj[]={-1,0,1,0};
int main(){
  ll h,w;
  cin>>h>>w;
  vstr ta(h);
  ll ans=0;
  rep(i,h) cin>>ta[i];
  rep(si,h) rep(sj,w){
    if(ta[si][sj]=='#') continue;
    vvll dist(h,vll(w,INF));
    queue<pll> q;
    auto j[&]=(ll i,ll j,ll x){
      if(dist[i][j]!=INF) return;
      dist[i][j]=x;
      q.pb(pll(i,j));
    };
    j(si,sj,0);
    while(!q.empty()){
      ll i=q.front().F;
      ll j=q.front().S;
      q.pop();
      rep(dir,4){
        ll ni=i+di[dir],nj=j+dj[i];
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(ta[ni][nj]=='#') continue;
        j(ni,nj,dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w){
      if(ta[i][j]=='#') continue;
      ans=max(ans,ta[i][j]);
    }
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:13: error: expected primary-expression before ']' token
   50 |     auto j[&]=(ll i,ll j,ll x){
      |             ^
a.cc:6:12: error: expected primary-expression before 'long'
    6 | #define ll long long
      |            ^~~~
a.cc:50:16: note: in expansion of macro 'll'
   50 |     auto j[&]=(ll i,ll j,ll x){
      |                ^~
a.cc:50:16: error: expected ')' before 'long'
   50 |     auto j[&]=(ll i,ll j,ll x){
      |               ~^
      |                )
a.cc:55:5: error: 'j' was not declared in this scope
   55 |     j(si,sj,0);
      |     ^
a.cc:64:10: error: 'j' cannot be used as a function
   64 |         j(ni,nj,dist[i][j]+1);
      |         ~^~~~~~~~~~~~~~~~~~~~
a.cc:69:14: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   69 |       ans=max(ans,ta[i][j]);
      |           ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:69:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'})
   69 |       ans=max(ans,ta[i][j]);
      |           ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:69:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |       ans=max(ans,ta[i][j]);
      |           ~~~^~~~~~~~~~~~~~