Language: C++

#include <bits/stdc++.h>

#define int long long
#define MOD 1000000007


#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int H,W;

void clear( queue<int> &q )
{
   queue<int> empty;
   swap( q, empty );
}


signed main(){
 
    cin>>H>>W;
    char A[H][W];
    
    rep(i,H){
        rep(j,W){
            cin>>A[i][j];
        }
    }
    
    int ans=0;


    //*から.までのユークリッド距離を調べる
     rep(i,H){
        rep(j,W){
            //cout<<i<<j<<endl;
            int temp=0;
            queue<pair<int, int>> pq;
            set<int> index;
            
                pq.push(mp(i,j));
                int hash = (i<<10) + j;
                index.insert(hash);
                while(pq.size()>0){
                    auto itr = pq.front();
                    pq.pop();
                    int f = itr.first;
                    int s = itr.second;

                  // cout<<itr.first<<itr.second<<endl;

                    if(A[itr.first][itr.second]=='#'){
                        temp = abs(i-itr.first)+abs(j-itr.second);
                       // cout<<i<<j<<" "<<itr.first<<itr.second<<" ";
                        //cout<<temp<<endl;
                        ans = max(ans,temp);
                        break;
                    }



                    if(f-1>=0){
                        hash = ((f-1)<<10) + s; 
                        if (index.find(hash) == index.end()){
                            index.insert(hash);
                            pq.push(mp(f-1,s));
                        }
                    }

                      if(f+1<H){
                        hash = ((f+1)<<10) + s; 
                        if (index.find(hash) == index.end()){
                            index.insert(hash);
                            pq.push(mp(f+1,s));
                        }
                    }

                      if(s-1>=0){
                        hash = (f<<10) + s-1; 
                        if (index.find(hash) == index.end()){
                            index.insert(hash);
                            pq.push(mp(f,s-1));
                        }
                    }

                      if(s+1<W){
                        hash = (f<<10) + s+1; 
                        if (index.find(hash) == index.end()){
                            index.insert(hash);
                            pq.push(mp(f,s+1));
                        }
                    }
                    

                }
            clear(pq);
            index.clear();
           // cout<<endl;
            
        }
    }



    cout << ans<<endl;

    return 0;
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:115:19: error: invalid initialization of reference of type 'std::queue<long long int>&' from expression of type 'std::queue<std::pair<long long int, long long int> >'
  115 |             clear(pq);
      |                   ^~
a.cc:31:25: note: in passing argument 1 of 'void clear(std::queue<long long int>&)'
   31 | void clear( queue<int> &q )
      |             ~~~~~~~~~~~~^