diff --git a/marathon_contest_template_v3/mmsnippets.cpp b/marathon_contest_template_v3/mmsnippets.cpp index d5ae6ec..838267f 100644 --- a/marathon_contest_template_v3/mmsnippets.cpp +++ b/marathon_contest_template_v3/mmsnippets.cpp @@ -143,29 +143,6 @@ inline uint32_t xrnd() { return y = y ^ (y << 5); } -struct Edge { -public: - int a, b, cost; - Edge () { - this->a = 0; - this->b = 0; - this->cost = 1000000; - } - Edge (int a, int b, int cost) { - this->a = a; - this->b = b; - this->cost = cost; - } - bool operator == (const Edge& t) const { return this->a == t.a && this->b == t.b; } -}; -namespace std { - template <> class hash { - public: - size_t operator()(const Edge& t) const{ return hash()(t.a<<16) | hash()(t.b); } - }; -} - - struct Edge { public: int a, b, cost; @@ -451,6 +428,7 @@ struct E512GridUtils { return r; } + // Direction static vector getEdges (E512Grid& g) { vector e; for (int y = 0; y < g.H; ++y) { @@ -464,7 +442,6 @@ struct E512GridUtils { } return e; } - static vector getEdges (E512Grid& g, int wall) { vector e; for (int y = 0; y < g.H; ++y) { @@ -479,7 +456,6 @@ struct E512GridUtils { } return e; } - static vector getEdges (E512Grid& g, E512Grid& horizontal, E512Grid& vertical) { vector e; for (int y = 0; y < g.H; ++y) { @@ -557,7 +533,7 @@ struct E512GridUtils { return mat; } - static vector< vector > getEdges2 (E512Grid& g, E512Grid& horizontal, E512Grid& vertical) { + static vector< vector > getVertEdges (E512Grid& g, E512Grid& horizontal, E512Grid& vertical) { vector e = E512GridUtils::getEdges(g, horizontal, vertical); vector< vector > r = vector< vector >(g.W*g.H, vector()); for (auto&& i : e) { @@ -566,6 +542,22 @@ struct E512GridUtils { return r; } + static vector toUnDirection (E512Grid& g, vector& e) { + vector t; + unordered_set us; + for (auto&& i : e) { + int a = i.a; + int b = i.b; + if (a > b) { swap(a, b); } + if (us.find(e512pos(a, b)) == us.end()) { + t.emplace_back(a, b, 1); + us.emplace(e512pos(a, b)); + } + } + e = t; + } + + static void rotateRight (E512Grid& g) { if (g.W != g.H) { return; } int n = g.W;