#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define N #define M #define WATCH(x) cout << (#x) << ": " << (x) << endl #define fWATCH(x, y) cout << x << ": " << y << endl #define tWATCH(x, y, z) cout << x << ": " << y << ", " << z << endl #define INFO(x) cout << "[ " << x << " ]\n" #define nINFO(n, x) cout << "[ " << to_string() << ": " << x << " ]\n" #define SUM(vec, init, fn) accumulate(vec.begin(), vec.end(), init, fn) template struct Pair { T1 x; T2 y; }; struct Range { int from; int to; }; using Str = string; template using Vec = vector; using StrVec = vector; using nMap = map; template using xMap = map; // #define FOR(from, to, what) for (auto i = from; i < to; i++) { what(i); } // #define FOR(from, to, from2, to2, what) for (auto j = from; j < to; j++) { for (auto i = from; i < to; i++) { what(i, j); } } typedef long int32; typedef unsigned long uint32; typedef long long ll; typedef unsigned long long uint64; #define toS(x) to_string(x) void print(ll line, int n) { for(int i = n - 1; i >= 0; i--) { if(line & (1 << (i + 1))) { cout << "X"; } else { cout << "."; } } cout << endl; } int main() { unsigned short r; int k; int index; ll line = 0; cin >> r >> k; Str input; cin >> input; string e = "." + input + "."; string base = ""; string r_string = "12345678"; for(int i = 0; i < 8; i++) { auto val = (r >> i) & 1; if(val) { r_string[i] = 'X'; } else r_string[i] = '.'; } for(auto i = 0; i < k; i++) { string temp = e; for(auto j = 1; j < e.length() - 1; j++) { int idx = 0; switch(e[j - 1]) { case 'X': idx = 4; break; } switch(e[j]) { case 'X': idx += 2; break; } switch(e[j + 1]) { case 'X': idx += 1; break; } temp[j] = r_string[idx]; cout << r_string[idx]; } cout << endl; e = temp; } /*for(auto i = 1; i < e.length()-1; i++) { line = line << 1; if(e[i] == 'X') line |= 1; index = (line >> i) & 7; } line = line << 1; for(auto i = 0; i < k; i++) { ll new_line = line; for (auto j = 0; j < e.length() - 2; j++) { auto idx = (line >> j) & 7; //cout << idx << " "; auto new_value = (r >> idx) & 1; //cout << new_value << " "; new_line &= ~(1 << (j + 1)); new_line |= new_value << (j + 1); } line = new_line; print(line, e.length() - 2); }*/ return 0; }