MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / search

Method search

code/other/algorithm_x.cpp:64–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 j->p->size++, j->d->u = j->u->d = j; \
63 c->r->l = c->l->r = c;
64 bool search(int k = 0) {
65 if (head == head->r) {
66 vi res(k);
67 rep(i,0,k) res[i] = sol[i];
68 sort(res.begin(), res.end());
69 return handle_solution(res); }
70 node *c = head->r, *tmp = head->r;
71 for ( ; tmp != head; tmp = tmp->r)
72 if (tmp->size < c->size) c = tmp;
73 if (c == c->d) return false;
74 COVER(c, i, j);
75 bool found = false;
76 for (node *r = c->d; !found && r != c; r = r->d) {
77 sol[k] = r->row;
78 for (node *j = r->r; j != r; j = j->r) {
79 COVER(j->p, a, b); }
80 found = search(k + 1);
81 for (node *j = r->l; j != r; j = j->l) {
82 UNCOVER(j->p, a, b); } }
83 UNCOVER(c, i, j);
84 return found; } };
85// vim: cc=60 ts=2 sts=2 sw=2:

Callers 1

testFunction · 0.45

Calls 1

handle_solutionFunction · 0.85

Tested by 1

testFunction · 0.36