132952025-01-07 12:39:21AGergoTom és Jerry 1 (80)cpp17Forditási hiba
#include <bits/stdc++.h>

using namespace std;
bool close;
int HolePos;
vector<int>TomTime;
vector<int>JerryTime;
vector<vector<int>> TomGraph;
vector<vector<int>> JerryGraph;

void TomSearch(int pos, int time)
{
    for(int x:TomGraph[pos])
    {
        if(TomTime[x] > time+1)
        {
            TomTime[x] = time+1;
            TomSearch(x,time+1);
        }
    }
}

void JerrySearch(int pos, int time)
{
    if(!close)
    {
        for(int x:JerryGraph[pos])
        {
            if(x == HolePos && TomTime[x]>time+1)
            {
                JerryTime[x] = time+1;
                close = true;

            }
            if(JerryTime[x] > time+1 && TomTime[x]>time+1)
            {
                JerryTime[x] = time+1;
                JerrySearch(x,time+1);
            }
        }
    }
}

int main()
{
    cin.tie(0);
    iostream::sync_with_stdio(0);

    int pointCount,edgeCount,TomPos,tries,e1,e2,width,JerryStart;
    cin >> pointCount >> edgeCount >> TomPos >> tries >> HolePos;
    TomTime.resize(pointCount,INT_MAX);
    JerryTime.resize(pointCount,INT_MAX);
    TomGraph.resize(pointCount+1,vector<int>());
    JerryGraph.resize(pointCount+1,vector<int>());
    vector<bool> ans(tries);

    vector<int> reset = JerryTime;
    for(int i = 0; i < edgeCount; i++)
    {
        cin >> e1 >> e2 >> width;

        if(width == 2)
        {
            TomGraph[e1].push_back(e2);
            TomGraph[e2].push_back(e1);
        }
        JerryGraph[e1].push_back(e2);
        JerryGraph[e2].push_back(e1);

    }

    TomSearch(TomPos,0);

    for(int i =0; i< tries; i++)
    {
        JerryTime = reset;
        close = false;
        cin >> JerryStart;
        JerrySearch(JerryStart,0);

        //cout << JerryTime[HolePos] << endl;

        if(JerryTime[HolePos] != INT_MAX)
        {
            ans[i] = true;
        }
        else
        {
            ans[i] = false;
        }

    }
    for(int c:ans)
    {
        if(c)
        {
            cout << "IGEN\n";
        }
        else
        {
            cout << "NEM\n";
        }

    }
}
Forditási hiba
open /var/local/lib/isolate/415/box/a.out: no such file or directory
main.cpp:4:6: error: 'bool close' redeclared as different kind of entity
    4 | bool close;
      |      ^~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/12/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:43,
                 from main.cpp:1:
/usr/include/unistd.h:358:12: note: previous declaration 'int close(int)'
  358 | extern int close (int __fd);
      |            ^~~~~
main.cpp: In function 'void JerrySearch(int, int)':
main.cpp:32:23: error: assignment of function 'int close(int)'
   32 |                 close = true;
      |                 ~~~~~~^~~~~~
main.cpp: In function 'int main()':
main.cpp:77:15: error: assignment of function 'int close(int)'
   77 |         close = false;
      |         ~~~~~~^~~~~~~