Leppy, I thought I understood what you said, and did these changes. still WA though!! Please help.
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define N 10005
#define NIL -1
#define INF 100000000
vector<int> adj[N];
int d[N];
int color[N];
int part[N];
int maxlength = 0;
int maxd;
//0- white
//1- black;
//2 - gray;
bool BFS(int n)
{
for(int start = 1; color[start] == 0 && start<=n ; start++)
{
color[start] = 2;
d[start] = 0;
part[start] = 1;
queue<int> q;
q.push(start);
while(!q.empty())
{
int v = q.front();
int size = adj[v].size();
for(int j=0; j<size; j++)
{
int x = adj[v][j];
// cout<<x<<" "<<v<<endl;
if(part[x] == part[v])
{
return false;
}
else
{
if(color[x]==0)
{
color[x] = 2;
d[x] = d[v] + 1;
part[x] = 3- part[v];
q.push(x);
}
}
}
q.pop();
color[v] = 1;
}
}
return true;
}
int main()
{
ios::sync_with_stdio(0);
int t;
cin>>t;
for(int k=1; k<=t; k++)
{
int n,m;
cin>>n>>m;
for(int i=1; i <=n; i++)
{
// if(i==start) continue;
color[i] = 0;
d[i] = INF;
part[i] = 0;
}
for(int i=0; i<=n; i++) adj[i].clear();
int a,b;
int root;
for(int i=0; i<m; i++)
{
cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
bool isBip = BFS(n);
cout<<"Scenario #"<<k<<":"<<"\n";
if(isBip) cout<<"No suspicious bugs found!"<<"\n";
else cout<<"Suspicious bugs found!"<<"\n";
}
return 0;
}