basic solution is stored as vector of int's (vector of var indices) and therefore you always need to run find() algorithm to check if certain var belongs to the basic solution or not. May be, it makes sense to have byte mask vector instead?

<pre>
vector&lt;uchar&gt; basic_solution_mask(var_num);
...
if (basic_solution_mask[i]) { ... } else {...}
</pre>

If you decide to make this modification, please, do not use vector&lt;bool&gt; - it's slow custom implementation of a vector and it's not recommended to use.