Language: C++

/**********************************### With The name of Allah ###**********************************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : 25 July, 2k20
|   Source      : Online Judge
|   Problem link:
|   Algorithm   :
|
\**============================================================================**/

#include "bits/stdc++.h"
using namespace std;

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};

#define MAX 1000006
int R, C, K;
pii start, target;
int dis[MAX][MAX];
const int INF = INT_MAX;
vector <string> grid;
bool processed[MAX][MAX];

void BFS()
{
    mem(processed, 0);
    for0(i, R)
    {
        for0(j, C)
        {
            dis[i][j] = INF;
        }
    }
    dis[start.ff][start.ss] = 0;

    deque<pii> dq;
    dq.push_back(start);

    while( dq.size() )
    {
        pii curr = dq.front();
        dq.pop_front();
        //if(processed[curr.ff][curr.ss])continue;
        processed[curr.ff][curr.ss] = 1;

        for0(i, 4)
        {
            int fx = dx4[i] + curr.ff;
            int fy = dy4[i] + curr.ss;
            int stroke = 0;
            while( isValid(fx, fy, R, C) and grid[fx][fy] == '.' and stroke < K && dis[fx][fy] >= dis[curr.ff][curr.ss] + 1)
            {
                if(!processed[fx][fy])
                {
                    dis[fx][fy] = dis[curr.ff][curr.ss] + 1;
                    dq.push_back( {fx, fy} );
                    processed[fx][fy] = 1;
                }
                stroke++;
                fx = fx + dx4[i];
                fy = fy + dy4[i];
            }
        }
    }

    if(dis[target.ff][target.ss] == INF)cout << "-1" << endl;
    else cout << dis[target.ff][target.ss] << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
     //FasterIO


    cin >> R >> C >> K;

    cin >> start.ff; start.ff--;
    cin >> start.ss; start.ss--;

    cin >> target.ff; target.ff--;
    cin >> target.ss; target.ss--;
    grid.clear();
    grid.resize(R);
    for(string &s: grid)cin >> s;

    BFS();
    return 0;
}

Compiler output:
/tmp/ccTiwiNs.o: in function `BFS()':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `processed' defined in .bss section in /tmp/ccTiwiNs.o
a.cc:(.text+0x120): relocation truncated to fit: R_X86_64_PC32 against symbol `processed' defined in .bss section in /tmp/ccTiwiNs.o
a.cc:(.text+0x1aa): relocation truncated to fit: R_X86_64_PC32 against symbol `processed' defined in .bss section in /tmp/ccTiwiNs.o
a.cc:(.text+0x26a): relocation truncated to fit: R_X86_64_PC32 against symbol `processed' defined in .bss section in /tmp/ccTiwiNs.o
a.cc:(.text+0x314): relocation truncated to fit: R_X86_64_PC32 against symbol `grid[abi:cxx11]' defined in .bss section in /tmp/ccTiwiNs.o
/tmp/ccTiwiNs.o: in function `main':
a.cc:(.text+0x5a5): relocation truncated to fit: R_X86_64_PC32 against symbol `grid[abi:cxx11]' defined in .bss section in /tmp/ccTiwiNs.o
a.cc:(.text+0x5bf): relocation truncated to fit: R_X86_64_PC32 against symbol `grid[abi:cxx11]' defined in .bss section in /tmp/ccTiwiNs.o
a.cc:(.text+0x5ce): relocation truncated to fit: R_X86_64_PC32 against symbol `grid[abi:cxx11]' defined in .bss section in /tmp/ccTiwiNs.o
/tmp/ccTiwiNs.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x654): relocation truncated to fit: R_X86_64_PC32 against symbol `grid[abi:cxx11]' defined in .bss section in /tmp/ccTiwiNs.o
a.cc:(.text+0x66d): relocation truncated to fit: R_X86_64_PC32 against symbol `grid[abi:cxx11]' defined in .bss section in /tmp/ccTiwiNs.o
collect2: error: ld returned 1 exit status