Getting a WA .what to do?
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
void addEdge(list adjList[],int x,int y){
adjList[x].pb(y);
adjList[y].pb(x);
}
void dfs(list adjList[],int src,bool visited[]){
visited[src]=true;
for(auto z:adjList[src]){
if(visited[z]==false){
dfs(adjList,z,visited);
}
}
}
int main(){
ll t,i=1;
cin>>t;
while(i<=t){
ll q,r;
cin>>q>>r;
list adjList[q];
bool *visited = new bool[q];
for(int i=0;i<q;i++){
visited[i] = false;
}
for(int i=0;i<r;i++){
ll x,y;
cin>>x>>y;
addEdge(adjList,x=x-1,y=y-1);
}
int c=0;
for(int i=0;i<q;i++){
if(visited[i]==false){
c++;
dfs(adjList,i,visited);
}
}
if(c==r){
cout<<“Scenario #”<<i<<":"<<endl;
cout<<“No suspicious bugs found!”<<endl;
}
else{
cout<<“Scenario #”<<i<<":"<<endl;
cout<<“Suspicious bugs found!”<<endl;
}
i++;
}
}