#include <bits/stdc++.h> using namespace std; bool dfsvisit(int j, vector<vector<int> >& vec, vector<bool>& visited, vector<int>& color){ stack<pair<int, int> > nq; nq.push(make_pair(j, 0)); pair<int, int> p; while(!nq.empty()){ p = nq.top(); nq.pop(); visited[p.first] = true; if(color[p.first]==-1){ if(p.second) color[p.first] = 1; else color[p.first] = 0; }else{ if(color[p.first]!=p.second) return false; } for(int i=0; i<vec[p.first].size(); i++){ if(!visited[vec[p.first][i]]){ if(color[p.first]) nq.push(make_pair(vec[p.first][i], 0)); else nq.push(make_pair(vec[p.first][i], 1)); } } } return true; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; scanf("%d", &t); for(int i=0; i<t; i++){ int n,m; scanf("%d %d", &n, &m); vector<int> color(n, -1); vector<vector<int> > vec(n); vector<bool> visited(n, 0); int a, b; for(int j=0; j<m; j++){ scanf("%d %d", &a, &b); a--; b--; vec[b].push_back(a); vec[a].push_back(b); } bool found = true; for(int j=0; j<n; j++){ if(!visited[j]){ found = found and dfsvisit(j, vec, visited, color); } if(!found) break; } printf("Scenario #%d:\n", i+1); if(found) printf("No suspicious bugs found!\n"); else printf("Suspicious bugs found!\n"); } } /* F:\temp\14639973.175578\Main.cc:2:25: error: bits/stdc++.h: No such file or directory F:\temp\14639973.175578\Main.cc:5: error: 'vector' has not been declared F:\temp\14639973.175578\Main.cc:5: error: expected ',' or '...' before '<' token F:\temp\14639973.175578\Main.cc: In function 'bool dfsvisit(int, int)': F:\temp\14639973.175578\Main.cc:6: error: 'stack' was not declared in this scope F:\temp\14639973.175578\Main.cc:6: error: 'pair' was not declared in this scope F:\temp\14639973.175578\Main.cc:6: error: expected primary-expression before 'int' F:\temp\14639973.175578\Main.cc:6: error: expected ';' before 'int' F:\temp\14639973.175578\Main.cc:7: error: 'nq' was not declared in this scope F:\temp\14639973.175578\Main.cc:7: error: 'make_pair' was not declared in this scope F:\temp\14639973.175578\Main.cc:8: error: expected primary-expression before 'int' F:\temp\14639973.175578\Main.cc:8: error: expected ';' before 'int' F:\temp\14639973.175578\Main.cc:10: error: 'p' was not declared in this scope F:\temp\14639973.175578\Main.cc:12: error: 'visited' was not declared in this scope F:\temp\14639973.175578\Main.cc:13: error: 'color' was not declared in this scope F:\temp\14639973.175578\Main.cc:19: error: 'vec' was not declared in this scope F:\temp\14639973.175578\Main.cc:21: error: 'color' was not declared in this scope F:\temp\14639973.175578\Main.cc: In function 'int main()': F:\temp\14639973.175578\Main.cc:31: error: 'ios_base' has not been declared F:\temp\14639973.175578\Main.cc:32: error: 'cin' was not declared in this scope F:\temp\14639973.175578\Main.cc:32: error: 'NULL' was not declared in this scope F:\temp\14639973.175578\Main.cc:32: error: 'cout' was not declared in this scope F:\temp\14639973.175578\Main.cc:34: error: 'scanf' was not declared in this scope F:\temp\14639973.175578\Main.cc:37: error: 'vector' was not declared in this scope F:\temp\14639973.175578\Main.cc:37: error: expected primary-expression before 'int' F:\temp\14639973.175578\Main.cc:37: error: expected ';' before 'int' F:\temp\14639973.175578\Main.cc:38: error: expected primary-expression before 'int' F:\temp\14639973.175578\Main.cc:38: error: expected ';' before 'int' F:\temp\14639973.175578\Main.cc:39: error: expected primary-expression before 'bool' F:\temp\14639973.175578\Main.cc:39: error: expected ';' before 'bool' F:\temp\14639973.175578\Main.cc:43: error: 'vec' was not declared in this scope F:\temp\14639973.175578\Main.cc:48: error: 'visited' was not declared in this scope F:\temp\14639973.175578\Main.cc:49: error: 'vec' was not declared in this scope F:\temp\14639973.175578\Main.cc:49: error: 'color' was not declared in this scope F:\temp\14639973.175578\Main.cc:53: error: 'printf' was not declared in this scope */ |
Double click to view unformatted code.