competitive-programming-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub kmyk/competitive-programming-library

:warning: graph/is_simple_graph.hpp

Depends on

Code

#pragma once
#include <set>
#include <vector>
#include "../utils/macros.hpp"

bool is_simple_graph(const std::vector<std::vector<int>> &g) {
    int n = g.size();
    REP (x, n) {
        std::set<int> used;
        for (int y : g[x]) {
            if (y == x or used.count(y)) {
                return false;
            }
            used.insert(y);
        }
    }
    return true;
}
#line 2 "graph/is_simple_graph.hpp"
#include <set>
#include <vector>
#line 2 "utils/macros.hpp"
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
#line 5 "graph/is_simple_graph.hpp"

bool is_simple_graph(const std::vector<std::vector<int>> &g) {
    int n = g.size();
    REP (x, n) {
        std::set<int> used;
        for (int y : g[x]) {
            if (y == x or used.count(y)) {
                return false;
            }
            used.insert(y);
        }
    }
    return true;
}
Back to top page