fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  6.  
  7. typedef pair<int,int>pr;
  8. #define all(i) i.begin() , i.end()
  9. #define ft first
  10. #define sn second
  11. #define pb push_back
  12.  
  13.  
  14. #define en "\n"
  15. #define dbg cout<<"rony\n";
  16.  
  17. #define MAXN 2010
  18. #define inf 1e8
  19. const int mod = 1e9+7;
  20. vector<int>g[MAXN];
  21. int vis[MAXN];
  22. int col[MAXN];
  23.  
  24. bool dfs(int nd,int c)
  25. {
  26. vis[nd] = 1;
  27. col[nd] = c;
  28.  
  29. bool ok = true;
  30. for(auto i:g[nd])
  31. {
  32. if(vis[i] == 1){
  33. if(col[nd] == col[i]) return false;
  34. continue;
  35. }
  36. ok &= dfs(i, c^1);
  37. }
  38. return ok;
  39. }
  40. void refrase(int n)
  41. {
  42. for(int i = 1;i <= n;i++){
  43. col[i] = 0;
  44. g[i].clear();
  45. vis[i] = 0;
  46. }
  47. }
  48. void solve()
  49. {
  50. int n,m;
  51. cin >> n >> m;
  52.  
  53. refrase(n);
  54. for(int i = 0;i < m;i++){
  55. int x,y;
  56. cin >> x >> y;
  57. g[x].pb(y);
  58. g[y].pb(x);
  59. }
  60.  
  61. bool ok = true;
  62. for(int i = 1;i <= n;i++){
  63. if(vis[i] == 1) continue;
  64. ok &= dfs(i,0);
  65. }
  66.  
  67. if(!ok) cout<<"Suspicious bugs found!\n";
  68. else cout<<"No suspicious bugs found!\n";
  69. }
  70. int main()
  71. {
  72. IOS;
  73. int t;
  74. t = 1;
  75.  
  76. cin >> t;
  77. int c = 0;
  78. while ( t-- )
  79. {
  80. cout<<"Scenario #"<<++c<<":\n";
  81. solve();
  82. }
  83. return 0;
  84. }
Runtime error #stdin #stdout 3.99s 2094364KB
stdin
Standard input is empty
stdout
Standard output is empty