#include #include #define DEBUG true #define $(x) \ { \ if (DEBUG) \ { \ std::cout << "(line " << __LINE__ << ") "; \ {x} std::cout << std::endl; \ } \ } #define _(x) \ { \ std::cout << #x << " = " << x << " "; \ } std::vector> loadLetterSym() { std::vector> result; for (size_t i = 0; i < 9; i++) { result.push_back({}); std::string line; std::getline(std::cin, line); for (size_t j = 0; j < 9; j++) { result[i].push_back(line[j]); } } return result; } std::vector decomposeSign(std::vector> letterSym) { std::vector> diffs; diffs.push_back({1, 0}); diffs.push_back({1, -1}); diffs.push_back({0, -1}); diffs.push_back({-1, -1}); diffs.push_back({-1, 0}); diffs.push_back({-1, 1}); diffs.push_back({0, 1}); diffs.push_back({1, 1}); std::vector result; for (size_t i = 0; i < diffs.size(); i++) { std::vector realPos = {4 + diffs[i][0], 4 + diffs[i][1]}; if (letterSym[realPos[0]][realPos[1]] == '#') { result.push_back(i); } } return result; } std::vector shiftSign(std::vector initSign, int diffShift) { std::vector> shifts; shifts.push_back({0, 1}); shifts.push_back({0, 2}); shifts.push_back({0, 3}); shifts.push_back({0, 4}); shifts.push_back({0, 5}); shifts.push_back({0, 6}); shifts.push_back({0, 7}); shifts.push_back({1, 2}); shifts.push_back({1, 3}); shifts.push_back({4, 6}); shifts.push_back({1, 4}); shifts.push_back({1, 5}); shifts.push_back({1, 6}); shifts.push_back({1, 7}); shifts.push_back({2, 3}); shifts.push_back({2, 4}); shifts.push_back({2, 5}); shifts.push_back({2, 6}); shifts.push_back({2, 7}); shifts.push_back({3, 4}); shifts.push_back({3, 5}); shifts.push_back({4, 7}); shifts.push_back({5, 6}); shifts.push_back({5, 7}); shifts.push_back({3, 6}); shifts.push_back({6, 7}); int initShift = 0; for (size_t i = 0; i < shifts.size(); i++) { if (shifts[i][0] == initSign[0] && shifts[i][1] == initSign[1]) { initShift = i; break; } } int realShift = (initShift + diffShift) % shifts.size(); return shifts[realShift]; } std::vector> composeSign(std::vector hands) { std::vector> result; for (size_t i = 0; i < 9; i++) { result.push_back({}); for (size_t j = 0; j < 9; j++) { result[i].push_back('.'); } } result[4][4] = '*'; std::vector> diffs; diffs.push_back({1, 0}); diffs.push_back({1, -1}); diffs.push_back({0, -1}); diffs.push_back({-1, -1}); diffs.push_back({-1, 0}); diffs.push_back({-1, 1}); diffs.push_back({0, 1}); diffs.push_back({1, 1}); for (const int handSign : hands) { std::vector diff = diffs[handSign]; std::vector currPos = {4, 4}; for (size_t i = 1; i <= 3; i++) { result[currPos[0] + i * diff[0]][currPos[1] + i * diff[1]] = '#'; } } return result; } int main() { // load input int N = -1, C = -1; std::cin >> N >> C; $(_(N)); $(_(C)); std::string line; std::getline(std::cin, line); // empty line for some reason for (int i = 0; i < N; i++) { std::vector> letterSym = loadLetterSym(); std::vector decomposed = decomposeSign(letterSym); std::vector shifted = shiftSign(decomposed, C); std::vector> result = composeSign(shifted); for (const auto line : result) { for (const auto symbol : line) { std::cout << symbol; } std::cout << std::endl; } } return 0; }