Skip to content

Commit

Permalink
Update mmsnippets.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ebicochineal committed Mar 3, 2024
1 parent d7018b2 commit c81b3dd
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions marathon_contest_template_v3/mmsnippets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Edge> {
public:
size_t operator()(const Edge& t) const{ return hash<int>()(t.a<<16) | hash<int>()(t.b); }
};
}


struct Edge {
public:
int a, b, cost;
Expand Down Expand Up @@ -451,6 +428,7 @@ struct E512GridUtils {
return r;
}

// Direction
static vector<Edge> getEdges (E512Grid& g) {
vector<Edge> e;
for (int y = 0; y < g.H; ++y) {
Expand All @@ -464,7 +442,6 @@ struct E512GridUtils {
}
return e;
}

static vector<Edge> getEdges (E512Grid& g, int wall) {
vector<Edge> e;
for (int y = 0; y < g.H; ++y) {
Expand All @@ -479,7 +456,6 @@ struct E512GridUtils {
}
return e;
}

static vector<Edge> getEdges (E512Grid& g, E512Grid& horizontal, E512Grid& vertical) {
vector<Edge> e;
for (int y = 0; y < g.H; ++y) {
Expand Down Expand Up @@ -557,7 +533,7 @@ struct E512GridUtils {
return mat;
}

static vector< vector<int> > getEdges2 (E512Grid& g, E512Grid& horizontal, E512Grid& vertical) {
static vector< vector<int> > getVertEdges (E512Grid& g, E512Grid& horizontal, E512Grid& vertical) {
vector<Edge> e = E512GridUtils::getEdges(g, horizontal, vertical);
vector< vector<int> > r = vector< vector<int> >(g.W*g.H, vector<int>());
for (auto&& i : e) {
Expand All @@ -566,6 +542,22 @@ struct E512GridUtils {
return r;
}

static vector<Edge> toUnDirection (E512Grid& g, vector<Edge>& e) {
vector<Edge> t;
unordered_set<e512pos> 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;
Expand Down

0 comments on commit c81b3dd

Please sign in to comment.