This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub suisen-cp/cp-library-cpp
#include "library/graph/remove_multiedges.hpp"
$\Theta(V+E)$ で多重辺を除去する。
#ifndef SUISEN_REMOVE_MULTIPLE_EDGES #define SUISEN_REMOVE_MULTIPLE_EDGES #include <algorithm> #include <vector> #include <cstdint> namespace suisen { void remove_multiedges(std::vector<std::vector<int>> &g) { std::vector<uint8_t> exists(g.size(), 0); for (auto &vs : g) { for (int v : vs) exists[v] = true; vs.erase(std::remove_if(vs.begin(), vs.end(), [&](int v) { return not std::exchange(exists[v], false); }), vs.end()); } } } // namespace suisen #endif // SUISEN_REMOVE_MULTIPLE_EDGES
#line 1 "library/graph/remove_multiedges.hpp" #include <algorithm> #include <vector> #include <cstdint> namespace suisen { void remove_multiedges(std::vector<std::vector<int>> &g) { std::vector<uint8_t> exists(g.size(), 0); for (auto &vs : g) { for (int v : vs) exists[v] = true; vs.erase(std::remove_if(vs.begin(), vs.end(), [&](int v) { return not std::exchange(exists[v], false); }), vs.end()); } } } // namespace suisen