Submission details
Task:Hypyt
Sender:False_Void1
Submission time:2025-11-07 16:22:56 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:106:45: error: expected statement at end of input
  106 |         else if (distFrom[start].count(end))
      |                                             ^
input/code.cpp:106:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  106 |         else if (distFrom[start].count(end))
      |         ^~~~
input/code.cpp:106:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  106 |         else if (distFrom[start].count(end))
      |                                             ^
input/code.cpp:106:45: error: expected '}' at end of input
input/code.cpp:93:5: note: to match this '{'
   93 |     {
      |     ^
input/code.cpp:106:45: error: expected '}' at end of input
  106 |         else if (distFrom[start].count(end))
      |                                             ^
input/code.cpp:61:1: note: to match this '{'
   61 | {
      | ^

Code

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

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long

ll n, m, q;
vector<vector<char> > grid;
vector<vector<ll> > rowSafe;
vector<vector<ll> > colSafe;
map<pair<ll, ll>, map<pair<ll, ll>, ll> > distFrom;

map<pair<ll, ll>, ll> bfsFrom(ll sr, ll sc)
{
    vector<vector<ll> > tempRow = rowSafe;
    vector<vector<ll> > tempCol = colSafe;

    map<pair<ll, ll>, ll> dist;
    queue<pair<ll, ll> > que;

    que.push(make_pair(sr, sc));
    dist[make_pair(sr, sc)] = 0;

    tempRow[sr].erase(find(tempRow[sr].begin(), tempRow[sr].end(), sc));
    tempCol[sc].erase(find(tempCol[sc].begin(), tempCol[sc].end(), sr));

    while (!que.empty())
    {
        pair<ll, ll> cur = que.front();
        que.pop();

        ll r = cur.first, c = cur.second;
        ll d = dist[cur];

        vector<ll> rowCells = tempRow[r];
        for (ll nc : rowCells)
        {
            tempRow[r].erase(find(tempRow[r].begin(), tempRow[r].end(), nc));
            tempCol[nc].erase(find(tempCol[nc].begin(), tempCol[nc].end(), r));
            dist[make_pair(r, nc)] = d + 1;
            que.push(make_pair(r, nc));
        }

        vector<ll> colCells = tempCol[c];
        for (ll nr : colCells)
        {
            tempCol[c].erase(find(tempCol[c].begin(), tempCol[c].end(), nr));
            tempRow[nr].erase(find(tempRow[nr].begin(), tempRow[nr].end(), c));
            dist[make_pair(nr, c)] = d + 1;
            que.push(make_pair(nr, c));
        }
    }

    return dist;
}

int main()
{
    fastio;
    cin >> n >> m >> q;

    grid.assign(n, vector<char>(m));
    rowSafe.assign(n, vector<ll>());
    colSafe.assign(m, vector<ll>());

    for (ll i = 0; i < n; i++)
        for (ll j = 0; j < m; j++)
        {
            cin >> grid[i][j];
            if (grid[i][j] == '.')
            {
                rowSafe[i].push_back(j);
                colSafe[j].push_back(i);
            }
        }

    vector<pair<ll, ll> > safeCells;
    for (ll i = 0; i < n; i++)
        for (ll j = 0; j < m; j++)
            if (grid[i][j] == '.')
                safeCells.push_back(make_pair(i, j));

    for (size_t i = 0; i < safeCells.size(); i++)
    {
        ll r = safeCells[i].first, c = safeCells[i].second;
        distFrom[make_pair(r, c)] = bfsFrom(r, c);
    }

    while (q--)
    {
        ll y1, x1, y2, x2;
        cin >> y1 >> x1 >> y2 >> x2;
        y1--;
        x1--;
        y2--;
        x2--;

        pair<ll, ll> start = make_pair(y1, x1);
        pair<ll, ll> end = make_pair(y2, x2);

        if (start == end)
            cout << 0 << "\n";
        else if (distFrom[start].count(end))