Advertisement
TheAnshul

BUGLIFE

Aug 20th, 2018
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***************************************************************************
  2.  * #######                    #                                            *
  3.  *    #     #    #  ######   # #    #    #   ####   #    #  #    #  #      *
  4.  *    #     #    #  #       #   #   ##   #  #       #    #  #    #  #      *
  5.  *    #     ######  #####  #     #  # #  #   ####   ######  #    #  #      *
  6.  *    #     #    #  #      #######  #  # #       #  #    #  #    #  #      *
  7.  *    #     #    #  #      #     #  #   ##  #    #  #    #  #    #  #      *
  8.  *    #     #    #  ###### #     #  #    #   ####   #    #   ####   ###### *
  9.  ***************************************************************************/
  10. #include<bits/stdc++.h>
  11. #define ll          long long
  12. #define pb          push_back
  13. #define endl        '\n'
  14. #define pii         pair<ll int,ll int>
  15. #define vi          vector<ll int>
  16. #define all(a)      (a).begin(),(a).end()
  17. #define F           first
  18. #define S           second
  19. #define sz(x)       (ll int)x.size()
  20. #define hell        1000000007
  21. #define rep(i,a,b)  for(ll int i=a;i<b;i++)
  22. #define lbnd        lower_bound
  23. #define ubnd        upper_bound
  24. #define bs          binary_search
  25. #define mp          make_pair
  26. using namespace std;
  27.  
  28. #define N  100005
  29.  
  30. int main()
  31. {
  32.     ios_base::sync_with_stdio(false);
  33.     cin.tie(0);
  34.     cout.tie(0);
  35.     int TESTS=1,fuck;
  36.     cin>>TESTS;
  37.     for(fuck=1;fuck<=TESTS;fuck++)
  38.     {
  39.         ll n,m,x,y;
  40.         cin>>n>>m;
  41.         vi col(n+1,-1);
  42.         vi a[n+1];
  43.         rep(i,0,m)
  44.         {
  45.             cin>>x>>y;
  46.             a[x].pb(y);
  47.             a[y].pb(x);
  48.         }
  49.         bool f=true;
  50.         ll top;
  51.         queue<ll>q;
  52.         rep(i,1,n+1)
  53.         {
  54.             if(col[i]==-1)
  55.             {
  56.                 q.push(i);
  57.                 col[i]=1;
  58.                 while(!q.empty() && f)
  59.                 {
  60.                     top=q.front();
  61.                     q.pop();
  62.                     for(auto j:a[top])
  63.                     {
  64.                         if(col[j]==-1)
  65.                         {
  66.                             col[j]=1-col[top];
  67.                             q.push(j);
  68.                         }
  69.                         if(col[j]==col[top])
  70.                         {
  71.                             f=false;
  72.                             break;
  73.                         }
  74.                     }
  75.                 }
  76.             }
  77.             if(!f)
  78.                 break;
  79.         }
  80.         if(!f)
  81.         {
  82.             cout<<"Scenario #"<<fuck<<":\nSuspicious bugs found!\n";
  83.         }
  84.         else
  85.             cout<<"Scenario #"<<fuck<<":\nNo suspicious bugs found!\n";    
  86.     }
  87.     return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement