#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
ll r,c,n;
vector<vector<ll>> grid;
vector<vector<ll>> visited;
bool iswithin(ll a, ll b, ll x, ll y){
if ((abs(x-a)<=n && abs(y-b) < n) || (abs(x-a)<n && abs(y-b) <= n)){
return 1;
}
return 0;
}
vector<vector<ll>> getvalid(ll a, ll b){
unordered_<vector<ll>> ans;
FOR(i,-(n-1), n){
ans.insert({a-n, b+i});
ans.insert({a+n, b+i});
ans.insert({a+i, b-n});
ans.insert({a+i, b+n});
}
FOR(i,0,r){
if (iswithin(a, b, i, c-1)) ans.insert({i, c-1});
if (iswithin(a, b, i, 0)) ans.insert({i, 0});
}
FOR(i,0,c){
if (iswithin(a,b,r-1,i)) ans.insert({r-1, i});
if (iswithin(a,b,0,i)) ans.insert({0, i});
}
vector<vector<ll>> realans;
for (auto&i : ans){
if (0<=i[0] && i[0]<r && 0<=i[1] && i[1]<c) realans.push_back(i);
}
return realans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> r >> c >> n;
ll a,b;
ll x,y;
cin >> a >> b >> x >> y;
a--;b--;x--;y--;
FOR(i,0,r){
vector<ll> temp;
vector<ll> idk;
string temp2;
cin >> temp2;
FOR(j,0,c){
temp.push_back(temp2[j]);
idk.push_back(100000000);
}
grid.push_back(temp);
visited.push_back(idk);
}
ll ans = -1;
deque<vector<ll>> sus;
sus.push_back({a,b,0});
visited[a][b] = 0;
while (sus.size()){
vector<ll> node = sus.front();
sus.pop_front();
if (visited[node[0]][node[1]] != node[2]) continue;
if (node[0] == x && node[1] == y){
ans = node[2];
break;
}
if (iswithin(node[0],node[1],x,y)){
if (visited[x][y]> node[2]+1){
visited[x][y] = node[2]+1;
sus.push_back({x,y,node[2]+1});
}
}
vector<vector<ll>> pos = {{node[0]-1,node[1]},{node[0]+1,node[1]},{node[0],node[1]-1},{node[0],node[1]+1}};
vector<vector<ll>> temp = getvalid(node[0], node[1]);
for (auto&i : pos){
if (0<=i[0] && i[0]<r && 0<=i[1] && i[1]<c){
if (grid[i[0]][i[1]] == '.'){
if (visited[i[0]][i[1]] > node[2]){
visited[i[0]][i[1]] = node[2];
sus.push_front({i[0], i[1], node[2]});
}
}
else{
if (visited[i[0]][i[1]] > node[2]+1 ){
visited[i[0]][i[1]] = node[2]+1;
sus.push_back({i[0], i[1], node[2]+1});
}
}
}
}
for (auto&i : temp){
if (0<=i[0] && i[0]<r && 0<=i[1] && i[1]<c){
if (visited[i[0]][i[1]] > node[2]+1){
visited[i[0]][i[1]] = node[2]+1;
sus.push_back({i[0], i[1], node[2]+1});
}
}
}
}
cout << ans << endl;
}
Compilation message
Main.cpp: In function 'std::vector<std::vector<long long int> > getvalid(ll, ll)':
Main.cpp:26:2: error: 'unordered_' was not declared in this scope
26 | unordered_<vector<ll>> ans;
| ^~~~~~~~~~
Main.cpp:26:22: error: expected primary-expression before '>' token
26 | unordered_<vector<ll>> ans;
| ^~
Main.cpp:26:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
26 | unordered_<vector<ll>> ans;
| ^~~
| abs