iam trying to apply bfs in a 2d grid but it's showing errors like:
error:variable or field 'bfs' declared void
error:missing template argument before 'a'
What I have tried:
#include <iostream>
#include
using namespace std;
vector<int> g[100];
int vis[100][100];
int dis[100][100];
int grid[100][100];
int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};
void bfs(pair a, pair b)
{
pair x=a;
memset(vis,0,sizeof vis);
vis[x.first][x.second]=1;
dis[x.first][x.second]=0;
queue<pair>q;
q.push(x);
while(!q.empty())
{
pair v=q.front();
for(int i=0;i<4;i++)
{
int c=v.first+fx[i];
int d=v.second+fy[i];
if(c>-1 and c<r and="" d="">-1 and d<c and="" mode="hold" /> {
dis[c][d]=dis[v.first][v.second]+1;
vis[c][d]=1;
pair y=make_pair(c,d);
q.push(y);
}
}
q.pop();
}
cout<<dis[b.first][b.second]<<endl;
}
int main()
{
while(cin>>r>>c)
{
if(r!=0&&c!=0)
{
memset(grid,0,sizeof grid);
int n;
cin>>n;
int row,number,col;
for(int i=0; i<n;> {
cin>>row>>number;
for(int j=0; j<number;> {
cin>>col;
grid[row][b]=1;
}
}
pair start,stop;
cin>>start.first>>start.second;
cin>>stop.first>>stop.second;
bfs(start,stop);
}
else
break;
}
return 0;
}