Language: C++

#include <bits/stdc++.h>
#define mins(x,y) (x=min(x,y))
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;

int main(){
    int n;
    cin >> n;
    
    vv cost(n,v (n));
    vv seat(n,v (n,1));
    
    rep(i,n)rep(j,n){
        cost[i][j] = i;
        mins(cost[i][j],j);
        mins(cost[i][j],n-1-i);
        mins(cost[i][j],n-1-j);
    }
    
    int ans = 0;
    
    v di={-1,0,1,0};
    v dj={0,-1,0,1};//四方
    
    for(int i=0; i<n*n; i++){
        int p;
        cin >> p;
        p--;
        int pi = p/n;
        int pj = p%n;
        
        ans += cost[pi][pj];
        seat[pi][pj] = 0;
        
        //幅優先で距離リストを更新
        queue<P> more;
        more.push(pi,pj);
        
        while(!more.empty()){
            
            int ni = more.front().first;
            int nj = more.front().second;
            int nc = cost[ni][nj]+seat[ni][nj];
            
            for(int l=0; l<4; l++){
                int mi = ni+di[l], mj = nj+dj[l];
                if(mi>=n || mi<0 || mj>=n || mj<0)continue;
                if(cost[mi][mj]<=nc)continue;
                
                cost[mi][mj] = nc;
                more.push(mi,mj);
                
            }
            more.pop();
        }
    }
    
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:18: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(int&, int&)'
   41 |         more.push(pi,pj);
      |         ~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note:   candidate expects 1 argument, 2 provided
a.cc:55:26: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(int&, int&)'
   55 |                 more.push(mi,mj);
      |                 ~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note:   candidate expects 1 argument, 2 provided