5441 2023. 06. 01 21:44:13 Timi Fantasztikus Kaland Nyílországban cpp14 Forditási hiba
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
bool Matrixban(int x, int y, int n, int m)
{
    return (x>=0 && x<n && y>=0 && y<m);
}

int Keres(int x, int y, int n, int m,vector<vector<char>>& a,
          vector<vector<bool>>& meglatogatott)
{
   meglatogatott[x][y]=true;
    if (x==n-1 && y==m-1)
        return 0;
    int md, minimum=100000000;
    bool ok=false;
    if (a[x][y]=='E')
    {
        if (Matrixban(x, y+1, n, m) && a[x][y+1]!='X' && !meglatogatott[x][y+1] )
        {
             md=szamol(x, y+1, n, m, a, meglatogatott);
             if (md!=-1 && md<minimum)
             {
                minimum=md;
                ok=true;
             }
        }


        if (Matrixban(x+1, y, n, m) && a[x+1][y]!='X' && !meglatogatott[x+1][y] )
        {
             md=szamol(x+1, y, n, m, a, meglatogatott);
        if (md!=-1 && md+1<minimum)
        {
                minimum=md+1;
                ok=true;
        }
        }

        if (Matrixban(x, y-1, n, m) && a[x][y-1]!='X' && !meglatogatott[x][y-1] )
        {
             md=szamol(x, y-1, n, m, a, meglatogatott);
        if (md!=-1 && md+2<minimum)
        {
                minimum=md+2;
                ok=true;
        }
        }

        if (Matrixban(x-1, y, n, m) && a[x-1][y]!='X' && !meglatogatott[x-1][y] )
        {
             md=szamol(x-1, y, n, m, a, meglatogatott);
        if (md!=-1 && md+3<minimum)
        {
                minimum=md+3;
                ok=true;
        }
        }

        if (ok)
            return minimum;
        else
            return -1;
    }

    if (a[x][y]=='N')
    {
        if (Matrixban(x-1, y, n, m) && a[x-1][y]!='X' && !meglatogatott[x-1][y] )
        {
             md=szamol(x-1, y, n, m, a, meglatogatott);
        if (md!=-1 && md<minimum)
        {
                minimum=md;
                ok=true;
        }
        }

        if (Matrixban(x, y+1, n, m) && a[x][y+1]!='X' && !meglatogatott[x][y+1] )
        {
             md=szamol(x, y+1, n, m, a, meglatogatott);
        if (md!=-1 && md+1<minimum)
        {
                minimum=md+1;
                ok=true;
        }
        }

        if (Matrixban(x+1, y, n, m) && a[x+1][y]!='X' && !meglatogatott[x+1][y] )
        {
            md=szamol(x+1, y, n, m, a, meglatogatott);
        if (md!=-1 && md+2<minimum)
        {
                minimum=md+2;
                ok=true;
        }
        }

        if (Matrixban(x, y-1, n, m) && a[x][y-1]!='X' && !meglatogatott[x][y-1] )
        {
             md=szamol(x, y-1, n, m, a, meglatogatott);
        if (md!=-1 && md+3<minimum)
        {
                minimum=md+3;
                ok=true;
        }
        }

        if (ok)
            return minimum;
        else
            return -1;
    }

    if (a[x][y]=='W')
    {
        if (Matrixban(x, y-1, n, m) && a[x][y-1]!='X' && !meglatogatott[x][y-1] )
        {
             md=szamol(x, y-1, n, m, a, meglatogatott);
        if (md!=-1 && md<minimum)
        {
                minimum=md;
                ok=true;
        }
        }

        if (Matrixban(x-1, y, n, m) && a[x-1][y]!='X' && !meglatogatott[x-1][y] )
        {
             md=szamol(x-1, y, n, m, a, meglatogatott);
        if (md!=-1 && md+1<minimum)
        {
                minimum=md+1;
                ok=true;
        }
        }

        if (Matrixban(x, y+1, n, m) && a[x][y+1]!='X' && !meglatogatott[x][y+1] )
        {
             md=szamol(x, y+1, n, m, a, meglatogatott);
        if (md!=-1 && md+2<minimum)
        {
                minimum=md+2;
                ok=true;
        }
        }

        if (Matrixban(x+1, y, n, m) && a[x+1][y]!='X' && !meglatogatott[x+1][y] )
        {
             md=szamol(x+1, y, n, m, a, meglatogatott);
        if (md!=-1 && md+3<minimum)
        {
                minimum=md+3;
                ok=true;
        }
        }

        if (ok)
            return minimum;
        else
            return -1;
    }

    if (a[x][y]=='S')
    {
        if (Matrixban(x+1, y, n, m) && a[x+1][y]!='X' && !meglatogatott[x+1][y] )
        {
             md=szamol(x+1, y, n, m, a, meglatogatott);
        if (md!=-1 && md<minimum)
        {
                minimum=md;
                ok=true;
        }
        }

        if (Matrixban(x, y-1, n, m) && a[x][y-1]!='X' && !meglatogatott[x][y-1] )
        {
             md=szamol(x, y-1, n, m, a, meglatogatott);
        if (md!=-1 && md+1<minimum)
        {
                minimum=md+1;
                ok=true;
        }
        }

        if (Matrixban(x-1, y, n, m) && a[x-1][y]!='X' && !meglatogatott[x-1][y] )
        {
             md=szamol(x-1, y, n, m, a, meglatogatott);
        if (md!=-1 && md+2<minimum)
        {
                minimum=md+2;
                ok=true;
        }
        }

        if (Matrixban(x, y+1, n, m) && a[x][y+1]!='X' && !meglatogatott[x][y+1] )
        {
             md=szamol(x, y+1, n, m, a, meglatogatott);
        if (md!=-1 && md+3<minimum)
        {
                minimum=md+3;
                ok=true;
        }
        }

        if (ok)
            return minimum;
        else
            return -1;
    }
   return -1;
}
int main()
{
    int n, m;
    cin>>n>>m;
    vector<vector<char>> a(n, vector<char>  (m));
    vector<vector<bool>> meglatogatott(n, vector<bool> (m));
    string s;
    for (int i=0; i<n; i++)
    {
        cin>>s;
        for (int j=0; j<m; j++)
        {
            a[i][j]=s[j];
            meglatogatott[i][j]=false;
        }

    }
    a[n-1][m-1]='A';


    cout<<Keres(0,0, n, m, a, meglatogatott);
    return 0;
}

Forditási hiba
exit status 1
main.cpp: In function 'int Keres(int, int, int, int, std::vector<std::vector<char> >&, std::vector<std::vector<bool> >&)':
main.cpp:22:17: error: 'szamol' was not declared in this scope
   22 |              md=szamol(x, y+1, n, m, a, meglatogatott);
      |                 ^~~~~~
main.cpp:33:17: error: 'szamol' was not declared in this scope
   33 |              md=szamol(x+1, y, n, m, a, meglatogatott);
      |                 ^~~~~~
main.cpp:43:17: error: 'szamol' was not declared in this scope
   43 |              md=szamol(x, y-1, n, m, a, meglatogatott);
      |                 ^~~~~~
main.cpp:53:17: error: 'szamol' was not declared in this scope
   53 |              md=szamol(x-1, y, n, m, a, meglatogatott);
      |                 ^~~~~~
main.cpp:71:17: error: 'szamol' was not declared in this scope
   71 |              md=szamol(x-1, y, n, m, a, meglatogatott);
      |                 ^~~~~~
main.cpp:81:17: error: 'szamol' was not declared in this scope
   81 |              md=szamol(x, y+1, n, m, a,...