Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define st first
- #define nd second
- #define mp make_pair
- #define pb push_back
- #define cl(x, v) memset((x), (v), sizeof(x))
- #define db(x) cerr << #x << " == " << x << endl
- #define dbs(x) cerr << x << endl
- #define _ << ", " <<
- #define gcd(x, y) __gcd((x), (y))
- typedef long long ll;
- typedef long double ld;
- typedef pair<int, int> pii;
- typedef pair<int, pii> piii;
- typedef pair<ll, ll> pll;
- typedef vector<int> vi;
- typedef vector<vi> vii;
- const ld EPS = 1e-9, PI = acos(-1.);
- const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
- const int INF = 0x3f3f3f3f, MOD = 1e9+7;
- const int N = 1e3+5;
- class Graph {
- int n;
- vector<vector<int>> adj;
- void dfs(int v, vector<bool> &vis) {
- if (vis[v]) return;
- vis[v] = true;
- for (int u : adj[v])
- dfs(u, vis);
- }
- public:
- void set_nodes(int _n) {
- n = _n;
- adj.assign(n+1, vector<int>());
- }
- void add_edge(int u, int v) {
- adj[u].pb(v);
- adj[v].pb(u);
- }
- string check_state() {
- vector<bool> vis;
- for (int i = 1; i <= n; i++) {
- vis.assign(n+1, false);
- dfs(i, vis);
- for (i = 1; i <= n; i++)
- if (!vis[i])
- return "falha";
- }
- return "normal";
- }
- };
- int main() {
- int e, l, t = 1;
- Graph *g = new Graph();
- while (cin >> e >> l, e+l) {
- g->set_nodes(e);
- for (int i = 0; i < l; i++) {
- int x, y; cin >> x >> y;
- g->add_edge(x,y);
- }
- cout << "Teste " << t++ << endl;
- cout << g->check_state() << endl;
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement