#include #include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) using namespace std; int main() { // input int h, w, n; scanf("%d%d%d", &h, &w, &n); vector a(w); repeat (y,h) repeat (x,w) { char c; scanf(" %c", &c); if (c =='#') a[x] += 1; } vector c(n); vector > c_inv(w-2); repeat (i,n) { scanf("%d", &c[i]); c_inv[c[i]].push_back(i); } // solve vector > b(n); repeat (x,w-2) { for (int i : c_inv[x]) { repeat (dx,3) { if (a[x + dx]) { a[x + dx] -= 1; b[i][dx] += 1; break; } } } } repeat (x,w) { repeat (dx,3) if (0 <= x-dx and x-dx < w-2) { for (int i : c_inv[x-dx]) { while (a[x] and b[i][dx] < 3) { a[x] -= 1; b[i][dx] += 1; } } } } // output for (auto & it : b) { repeat (y,3) { repeat (x,3) { printf("%c", 3-y-1 < it[x] ? '#' : '.'); } printf("\n"); } } return 0; }