#include <iostream>
#include <vector>
bool increase(std::vector<bool>& v)
{
for (std::size_t i = 0; i != v.size(); ++i) {
v[i] = !v[i];
if (v[i] == true) {
return true;
}
}
return false;
}
int main()
{
std::vector<bool> v(5);
do {
for (std::size_t i = 0; i != v.size(); ++i) {
std::cout << v[i] << " ";
}
std::cout << std::endl;
} while (increase(v));
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKCmJvb2wgaW5jcmVhc2Uoc3RkOjp2ZWN0b3I8Ym9vbD4mIHYpCnsKICAgIGZvciAoc3RkOjpzaXplX3QgaSA9IDA7IGkgIT0gdi5zaXplKCk7ICsraSkgewogICAgICAgIHZbaV0gPSAhdltpXTsKICAgICAgICBpZiAodltpXSA9PSB0cnVlKSB7CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBmYWxzZTsKfQoKaW50IG1haW4oKQp7CiAgICBzdGQ6OnZlY3Rvcjxib29sPiB2KDUpOwoKICAgIGRvIHsKICAgICAgICBmb3IgKHN0ZDo6c2l6ZV90IGkgPSAwOyBpICE9IHYuc2l6ZSgpOyArK2kpIHsKICAgICAgICAgICAgc3RkOjpjb3V0IDw8IHZbaV0gPDwgIiAiOwogICAgICAgIH0KICAgICAgICBzdGQ6OmNvdXQgPDwgc3RkOjplbmRsOwogICAgfSB3aGlsZSAoaW5jcmVhc2UodikpOwogICAgcmV0dXJuIDA7Cn0K