#include #include #include #include #include int main ( ) { //std::vector> firstNum; int n; std::string radek; std::cin >> n; //std::getline(std::cin,radek); //zbytecne int cols,currentIndex; int lastIndex = 0; int a,b; for (int i = 0; i < n; i++) { //currentIndex = i; std::cin >>radek; cols = radek.size(); if (n == 1 && cols == 1) { //to je 1, ale co nula??? a = 1; break; } if (!i) { for (size_t j = 0; j < cols; j++) { if (radek[j] == '#') { currentIndex = j; a = 2; } } } else if (i == n -1) { for (size_t j = 0; j < cols; j++) if (radek[j] == '#') currentIndex = j; if (lastIndex > currentIndex) { a++; } } else { for (size_t j = 0; j < cols; j++) if (radek[j] == '#') currentIndex = j; if (lastIndex > currentIndex) { a++; } a = a*2; } lastIndex = currentIndex; } //std::cout << a << std::endl; std::cin >> n; for (int i = 0; i < n; i++) { //currentIndex = i; std::cin >>radek; cols = radek.size(); if (n == 1 && cols == 1) { //to je 1, ale co nula??? b= 1; break; } if (!i) { for (size_t j = 0; j < cols; j++) { if (radek[j] == '#') { currentIndex = j; b= 2; } } } else if (i == n -1) { for (size_t j = 0; j < cols; j++) if (radek[j] == '#') currentIndex = j; if (lastIndex > currentIndex) { b++; } } else { for (size_t j = 0; j < cols; j++) if (radek[j] == '#') currentIndex = j; if (lastIndex > currentIndex) { a++; } b= b*2; } lastIndex = currentIndex; } //std::cout << a << std::endl; //std::cout << b << std::endl; int c = a + b; std::vector res; int resCurrent = 0; res.push_back(resCurrent); int resMax = 0; int resMin = 0; while (c >= 1) { if (c % 2 == 1) { resCurrent = resCurrent -1; if (resMin > resCurrent) resMin = resCurrent; c = floor(c/2); res.push_back(resCurrent); // std::cout << "lol" << std::endl; } else { resCurrent = resCurrent + 1; if (resMax < resCurrent) resMax = resCurrent; if (c == 2) c = 0; else c = c/2; res.push_back(resCurrent); } } std::vector resVector; resVector.reserve(res.size()); std::cout << res.size() << std::endl; for (int i = 0; i < res.size();i++) { for (int j = resMin; j <= resMax; j++) { if (res[i] == j) resVector[i].push_back('#'); else resVector[i].push_back('.'); } std::reverse(resVector[i].begin(),resVector[i].end()); //std::cout << resVector[i] << std::endl; } // std::reverse(resVector.begin(),resVector.end()); for ( int i = res.size()-1; i >= 0 ; i -- ) { std::cout << resVector[i] << std::endl; } return 0; }