Language: C++

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 21;
struct point {
    ll x, y;
    char dir;
    bool operator == (const point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (const point b)
    {
        return !(*this == b);
    }
    friend bool operator < (const point a, const point b)
    {
        if(a.x != b.x)
            return a.x < b.x;
        if(a.y != b.y)
            return a.y < b.y;
        return int(a.dir) < int(b.dir);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

char dir(int x, int y)
{
    if(x == 1) return 'W';
    if(x == -1) return 'E';
    if(y == 1) return 'S';
    return 'N';
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 1, y = INF, anss = 0, k, x1, x2, y1, y2;
        cin >> n >> m >> k;
        cin >> x1 >> y1 >> x2 >> y2;
        char c;
        set<point> v;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            {
                cin >> c;
                if(c != '.')
                {
                    point tmp;
                    tmp.x = i;
                    tmp.y = j;
                    tmp.dir = 'E';
                    v.insert(tmp);
                    tmp.dir = 'W';
                    v.insert(tmp);
                    tmp.dir = 'S';
                    v.insert(tmp);
                    tmp.dir = 'N';
                    v.insert(tmp);
                }
            }
        }
        map<point, ld> d;
        point start;
        start.x = x1, start.y = y1, start.dir = 'O';
        d[start] = 0;
        set<pair<ld,point>> s;
        s.insert({0, start});
        while(!s.empty())
        {
            point p = s.begin() -> ss;
            ld dist = s.begin() -> ff;
            s.erase(s.begin());
            if(v.find(p) != v.end()) continue;
            v.insert(p);
            for(int i = -1; i < 2; i++)
            {
                for(int j = -1; j < 2; j++)
                {
                    if(abs(i) + abs(j) != 1) continue;
                    point tmp = p;
                    tmp.x += i;
                    tmp.y += j;
                    tmp.dir = dir(i, j);
                    if(tmp.x > 0 && tmp.x < n + 1 && tmp.y > 0 && tmp.y < m + 1)
                    {
                        if(v.find(tmp) != v.end()) continue;
                        if(d.find(tmp) == d.end())
                            d[tmp] = 10000000000;
                        ld newDist = dist;
                        if(tmp.dir == p.dir)
                        {
                            newDist += (ld)1 / k;
                        }
                        else newDist = ceil(newDist) + (ld)1 / k;
                        if(newDist <= d[tmp])
                        {
                            d[tmp] = newDist;
                            s.insert({newDist, tmp});
                        }
                    }
                }
            }
        }
        point tmp;
        tmp.x = x2;
        tmp.y = y2;
        ld ans = 1000000000000;
        tmp.dir = 'E';
        if(d.find(tmp) != d.end())
            ans = min(ans, d[tmp]);
        tmp.dir = 'W';
        if(d.find(tmp) != d.end())
            ans = min(ans, d[tmp]);
        tmp.dir = 'N';
        if(d.find(tmp) != d.end())
            ans = min(ans, d[tmp]);
        tmp.dir = 'S';
        if(d.find(tmp) != d.end())
            ans = min(ans, d[tmp]);
        ans = ceil(ans)
        if(ans < 1000000000000)
            cout << ans << "\n";
        else cout << "-1\n";
     }
     return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:163:24: error: expected ';' before 'if'
  163 |         ans = ceil(ans)
      |                        ^
      |                        ;
  164 |         if(ans < 1000000000000)
      |         ~~              
a.cc:166:9: error: 'else' without a previous 'if'
  166 |         else cout << "-1\n";
      |         ^~~~