| 23 | }; |
| 24 | |
| 25 | int main() { |
| 26 | vector<Example> examples = { |
| 27 | {{0, 1, 2}, 3}, |
| 28 | {{0, 1, 3}, 2}, |
| 29 | {{0, 2, 3}, 1}, |
| 30 | {{1, 2, 3}, 0}, |
| 31 | }; |
| 32 | |
| 33 | for (auto example : examples) { |
| 34 | assert(MexSimple::mex(example.array) == example.mex); |
| 35 | assert(MexLinear::mex(example.array) == example.mex); |
| 36 | } |
| 37 | |
| 38 | vector<int> A = {1, 2, 4, 1, 4}; |
| 39 | auto mex = MexUpdate::Mex(A); |
| 40 | assert(mex.mex() == 0); // array = {1, 2, 4, 1, 4} |
| 41 | mex.update(3, 0); |
| 42 | assert(mex.mex() == 3); // array = {1, 2, 4, 0, 4} |
| 43 | mex.update(2, 0); |
| 44 | assert(mex.mex() == 3); // array = {1, 2, 0, 0, 4} |
| 45 | mex.update(3, 3); |
| 46 | assert(mex.mex() == 5); // array = {1, 2, 0, 3, 4} |
| 47 | mex.update(4, 3); |
| 48 | assert(mex.mex() == 4); // array = {1, 2, 0, 3, 3} |
| 49 | mex.update(4, 9); |
| 50 | assert(mex.mex() == 4); // array = {1, 2, 0, 9, 9} |
| 51 | mex.update(3, 9); |
| 52 | assert(mex.mex() == 3); // array = {1, 2, 0, 9, 9} |
| 53 | } |
nothing calls this directly
no outgoing calls
no test coverage detected