Language: C++

/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
string s[30];
int h,w;
int dist[30][30];

bool poss(int i,int j){
   return i<h and j<w and i>=0 and j>=0 and s[i][j] == '.';
}
int main()
{
    IOS();
   cin >> h >> w;
      f(i,0,h){
         cin >> s[i];
      }
      int ans = 0;
      f(i,0,h)
      {
         f(j,0,w)
         {
            if(s[i][j] == '.')
            {
               set<array<int,3>> q;
               int mx = 0;
               q.insert({0,i,j});
               vector<vector<int>> dist(h,vector<int>(w,MOD));
               dist[i][j] = 0;
               while(!q.empty())
               {
                  auto v = *q.begin();
                  q.erase(q.begin());
                  int ff = v[1];
                  int ss = v[2];
                  vector<pii> itr = {{ff+1,ss},{ff-1,ss},{ff,ss+1},{ff,ss-1}};
                  for(auto &e : itr)
                  {
                     if(poss(e.F,e.S))
                     {
                        if(dist[ff][ss]+1<dist[e.F][e.S])
                        {
                           q.erase({dist[e.F][e.S],e.F,e.S});
                           dist[e.F][e.S] = dist[ff][ss]+1;
                           mx = max(mx,dist[e.F][e.S]);
                           q.insert({dist[e.F][e.S],e.F,e.S});
                        }
                     }
                  }
               }
               ans = max(ans,mx);
            }
         }
      }
      cout << ans << '\n';
      return 0;
   }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'i' was not declared in this scope
   43 |       f(i,0,h){
      |         ^
a.cc:12:22: note: in definition of macro 'f'
   12 | #define f(i,x,n) for(i=x;i<n;i++)
      |                      ^
a.cc:47:9: error: 'i' was not declared in this scope
   47 |       f(i,0,h)
      |         ^
a.cc:12:22: note: in definition of macro 'f'
   12 | #define f(i,x,n) for(i=x;i<n;i++)
      |                      ^
a.cc:49:12: error: 'j' was not declared in this scope
   49 |          f(j,0,w)
      |            ^
a.cc:12:22: note: in definition of macro 'f'
   12 | #define f(i,x,n) for(i=x;i<n;i++)
      |                      ^
a.cc:55:24: error: no matching function for call to 'std::set<std::array<int, 3> >::insert(<brace-enclosed initializer list>)'
   55 |                q.insert({0,i,j});
      |                ~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >]'
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::array<int, 3> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::rebind<std::array<int, 3> >; typename _Alloc::value_type = std::array<int, 3>; value_type = std::array<int, 3>]'
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:511:32: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::set<std::array<int, 3> >::value_type&' {aka 'const std::array<int, 3>&'}
  511 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:520:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::array<int, 3> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::rebind<std::array<int, 3> >; typename _Alloc::value_type = std::array<int, 3>; value_type = std::array<int, 3>]'
  520 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:520:27: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::array<int, 3> >::value_type&&' {aka 'std::array<int, 3>&&'}
  520 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:548:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, const value_type&) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >; iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; const_iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; value_type = std::array<int, 3>]'
  548 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:548:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:553:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, value_type&&) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >; iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; const_iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; value_type = std::array<int, 3>]'
  553 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:553:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:580:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >]'
  580 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:580:43: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::array<int, 3> >'
  580 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:600:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::insert_return_type std::set<_Key, _Compare, _Alloc>::insert(node_type&&) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >; insert_return_type = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::insert_return_type; node_type = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::node_type]'
  600 |       insert(node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:600:26: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::array<int, 3> >::node_type&&' {aka 'std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::node_type&&'}
  600 |       insert(node_type&& __nh)
      |              ~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_set.h:605:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, node_type&&) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >; iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; const_iterator = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::const_iterator; node_type = std::_Rb_tree<std::array<int, 3>, std::array<int, 3>, std::_Identity<std::array<int, 3> >, std::less<std::array<int, 3> >, std::allocator<std::array<int, 3> > >::node_type]'
  605 |       insert(const_iterator __hint, node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:605:7: note:   candidate expects 2 arguments, 1 provided
a.cc:64:26: error: 'pii' was not declared in this scope
   64 |                   vector<pii> itr = {{ff+1,ss},{ff-1,ss},{ff,ss+1},{ff,ss-1}};
      |                          ^~~
a.cc:64:29: error: template argument 1 is invalid
   64 |                   vector<pii> itr = {{ff+1,ss},{ff-1,ss},{ff,ss+1},{ff,ss-1}};
      |                             ^
a.cc:64:29: error: template argument 2 is invalid
a.cc:64:31: error: scalar object 'itr' requires one element in initializer
   64 |                   vector<pii> itr = {{ff+1,ss},{ff-1,ss},{ff,ss+1},{ff,ss-1}};
      |                               ^~~
a.cc:71:35: error: no matching function for call to 'std::set<std::array<int, 3> >::erase(<brace-enclosed initializer list>)'
   71 |                            q.erase({dist[e.F][e.S],e.F,e.S});
      |                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:656:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(const_iterator) [with _Key = std::array<int, 3>; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::array<int, 3> >; iterator = std::_Rb_tree<std::array<int, 3>, std::