Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

What is the problem in my code BUGLIFE — A Bug’s Life spoj?

Правка en4, от optimus2409, 2020-10-06 21:57:52
#include <bits/stdc++.h>
using namespace std;

bool isb(vector<bool>& visited,vector<bool>& color,vector<int> adj[],int v)

{

    for(int u:adj[v])

    {

        if(visited[u]==false)
        {
            visited[u]=true;
            color[u]=!color[v];
            if(!isb(visited,color,adj,u))
            {
                return false;
            }
        }
        else if(color[u]==color[v])
        {
            return false;
        }
    }
    return true;
}

vector<int> adj[1000005];
  vector<bool> visited(2005);
 vector<bool> color(2005);

int main()
{
 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 srand(chrono::high_resolution_clock::now().time_since_epoch().count());

 int t,b,in,x,y;
  
 cin >> t;

 for(int j=1;j<=t;j++) {
 cin>>b>>in;
visited.clear();
color.clear();
for(auto& vec: adj){vec.clear();}
 for(int i=0;i<in;i++)
 {
     cin>>x>>y;
     adj[x].push_back(y);
     adj[y].push_back(x);
 }
 visited[1]=true;
 color[1]=0;
if(isb(visited,color,adj,1))
{
    cout<<"Scenario #"<<j<<":"<<endl;
    cout<<"No suspicious bugs found!"<<endl;
}
else
{
    cout<<"Scenario #"<<j<<":"<<endl;
    cout<<"Suspicious bugs found!"<<endl;
}
 }

 return 0;
}

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский optimus2409 2020-10-06 21:57:52 20
en3 Английский optimus2409 2020-10-06 21:56:03 10
en2 Английский optimus2409 2020-10-06 21:54:29 2
en1 Английский optimus2409 2020-10-06 21:52:14 1312 Initial revision (published)