Language: C++

#include<bits/stdc++.h>
#define ll long long
vector<pair<ll,ll>>v[1000001];
char c[1001][1001];
int main() {
    ll n,m;
    cin>>n>>m;
    ll l,r;
    cin>>l>>r;
    ll s=l*(r-1)+r;
    cin>>l>>r;
    ll e=l*(r-1)+r;
    for(ll i=1; i<=n; i++) {
        for(ll j=1; j<=m; j++) {
            cin>>c[i][j];
        }
    }
    for(ll i=1; i<=n; i++) {
        for(ll j=1; j<=m; j++) {
            if(c[i][j]=='.'){
                for(ll k=i-2; k<=i+2; k++) {
                    for(ll h=j-2; h<=j+2; h++) {
                        if(k>=1 && k<=n && h>=1 && h<=m) {
                            if(c[k][h]=='.') {
                                if(abs(i-k)+abs(j-h)==1)
                                    v[i*(j-1)+j].push_back({k*(h-1)+h,0});
                                else if(abs(i-k)+abs(j-h)>1)
                                    v[i*(j-1)+j].push_back({k*(h-1)+h,1});
                            }
                        }
                    }
                }
            }
        }
    }
    ll dist[n*m+1];
    for(ll i=0; i<=n*m; i++) dist[i]=1e18;
    dist[s]=0;
    set<pair<ll,ll>>pq;
    pair<ll,ll>p;
    pq.insert({s,0});
    while(!pq.empty()) {
        p=*pq.begin();
        pq.erase(pq.begin());
        if(dist[p.first]!=p.second) continue;
        for(auto it:v[p.first]) {
            if(dist[it.first]>dist[p.first]+it.second) {
                dist[it.first]=dist[p.first]+it.second;
                pq.insert({it.first,dist[it.first]});
            }
        }
    }
    if(dist[e]==1e18) cout<<-1<<endl;
    else cout<<dist[e]<<endl;
    return 0;
}


Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<pair<ll,ll>>v[1000001];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |     cin>>n>>m;
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:26:37: error: 'v' was not declared in this scope
   26 |                                     v[i*(j-1)+j].push_back({k*(h-1)+h,0});
      |                                     ^
a.cc:28:37: error: 'v' was not declared in this scope
   28 |                                     v[i*(j-1)+j].push_back({k*(h-1)+h,1});
      |                                     ^
a.cc:39:5: error: 'set' was not declared in this scope
   39 |     set<pair<ll,ll>>pq;
      |     ^~~
a.cc:39:5: note: suggested alternatives:
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158:
/usr/include/c++/14/bits/stl_set.h:96:11: note:   'std::set'
   96 |     class set
      |           ^~~
/usr/include/c++/14/set:87:13: note:   'std::pmr::set'
   87 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
a.cc:39:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   39 |     set<pair<ll,ll>>pq;
      |         ^~~~
      |         std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:39:14: note: in expansion of macro 'll'
   39 |     set<pair<ll,ll>>pq;
      |              ^~
a.cc:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:40:10: note: in expansion of macro 'll'
   40 |     pair<ll,ll>p;
      |          ^~
a.cc:41:5: error: 'pq' was not declared in this scope
   41 |     pq.insert({s,0});
      |     ^~
a.cc:43:9: error: 'p' was not declared in this scope
   43 |         p=*pq.begin();
      |         ^
a.cc:46:21: error: 'v' was not declared in this scope
   46 |         for(auto it:v[p.first]) {
      |                     ^
a.cc:53:23: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   53 |     if(dist[e]==1e18) cout<<-1<<endl;
      |                       ^~~~
      |                       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:53:33: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   53 |     if(dist[e]==1e18) cout<<-1<<endl;
      |                                 ^~~~
      |                                 std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:54:10: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   54 |     else cout<<dist[e]<<endl;
      |          ^~~~
      |          std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:54:25: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   54 |     else cout<<dist[e]<<endl;
      |                         ^~~~
      |                         std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~