fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. bool bfs(ll i,vector<int> v[],bool mark[],bool color[]){
  5. color[i]=0;
  6. mark[i]=1;
  7. ll j;
  8. queue<int> q;
  9. q.push(i);
  10. while(!q.empty()){
  11. j=q.front();
  12. q.pop();
  13. for(ll k=0;k<v[j].size();k++){
  14. if(!mark[v[j][k]]){
  15. mark[v[j][k]]=1;
  16. if(color[j])
  17. color[v[j][k]]=0;
  18. else
  19. color[v[j][k]]=1;
  20. q.push(v[j][k]);
  21. }
  22. else{
  23. if(color[j]==color[v[j][k]])
  24. return 1;
  25. }
  26. }
  27. }
  28. return 0;
  29. }
  30. int main()
  31. {
  32. int t,t1=1;
  33. cin>>t;
  34. while(t1<=t){
  35. ll n,e,a,b;
  36. cin>>n>>e;
  37. vector<int> v[n+1];
  38. bool mark[n+1];
  39. bool color[n+1];
  40. memset(mark,0,n+1);
  41. for(ll i=0;i<e;i++){
  42. cin>>a>>b;
  43. v[a].push_back(b);
  44. }
  45. cout<<"Scenario #"<<t1<<":"<<endl;
  46. for(ll i=1;i<=n;i++){
  47. if(!mark[i]){
  48. if(bfs(i,v,mark,color)){
  49. cout<<"Suspicious bugs found!"<<endl;
  50. goto here;
  51. }
  52. }
  53. }
  54. cout<<"No suspicious bugs found!"<<endl;
  55. here:t1++;
  56.  
  57. }
  58.  
  59. }
Runtime error #stdin #stdout 0s 4568KB
stdin
Standard input is empty
stdout
Standard output is empty