#include #include #include #include constexpr size_t mx = (1 << 11) + 1; std::vector nb(mx); void visit(const std::string& w) { if (w.length() < mx) { nb[w.length()]++; std::stringstream sw1; std::stringstream sw2; char d1 = '\001'; char d2 = '\002'; for (const char r : w) { for (char i = 0; i= mx) { return; } d1 = 3-d1; d2 = 3-d2; } visit(sw1.str()); visit(sw2.str()); } } int main() { nb[1] = 1; // for the word "1" visit("\002"); for (size_t n = 1; n < mx; n++) { std::cout << n << ' ' << nb[n] << std::endl; } return 0; }