i am getting error no output is printed
Anyone is there can you help me out?
#include<bits/stdc++.h>
using namespace std;
int n;
bool bipartite(vectorg[])
{
int color[n];
cout<<“1”;
cout<<g[0][1];
int v[n];
for(int i=0;i<n;i++)
{
color[i]=-1;
v[i]=-1;
}
for(int i=0;i<n;i++)
{
if(v[i]==-1)
{
queue q;
q.push(i);
v[i]=1;
color[i]=1;
while(!q.empty())
{
int f=q.front();
q.pop();
for(int i=0;i<g[f].size();i++)
{
if(v[i]!=-1)
{
color[i]=1-color[f];
q.push(i);
v[i]=1;
}
else
{
if(color[i]==color[f])
{
return false;
}
}
}
}
}
}
return true;
}
int main()
{
cin>>n;
vector<int> z[n];
int x,y;
for(int i=0;i<n;i++)
{
cin>>x>>y;
z[x].push_back(y);
}
bool ans1 =bipartite(z);
cout<<ans1;
}
are u there brother reply please?
bro can you tell me what is the error in my code ?
your code is difficult to understand . So unable to find error in your code.