| 13291 | 2025-01-07 12:26:15 | AGergo | Tom és Jerry 1 (80) | cpp17 | Forditási hiba |
#include <bits/stdc++.h>
using namespace std;
vector<int>TomTime;
vector<int>JerryTime;
vector<vector<int>> TomGraph;
vector<vector<int>> JerryGraph;
TomSearch(int pos, int time)
{
for(int x:TomGraph[pos])
{
if(TomTime[x] > time+1)
{
TomTime[x] = time+1;
TomSearch(x,time+1);
}
}
}
JerrySearch(int pos, int time)
{
for(int x:JerryGraph[pos])
{
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,HolePos,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;
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";
}
}
}
open /var/local/lib/isolate/438/box/a.out: no such file or directory
main.cpp:9:1: error: ISO C++ forbids declaration of 'TomSearch' with no type [-fpermissive]
9 | TomSearch(int pos, int time)
| ^~~~~~~~~
main.cpp: In function 'int TomSearch(int, int)':
main.cpp:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
19 | }
| ^
main.cpp: At global scope:
main.cpp:21:1: error: ISO C++ forbids declaration of 'JerrySearch' with no type [-fpermissive]
21 | JerrySearch(int pos, int time)
| ^~~~~~~~~~~
main.cpp: In function 'int JerrySearch(int, int)':
main.cpp:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
31 | }
| ^