luogu#P6368. [COCI 2006/2007 #6] MAGIJA

[COCI 2006/2007 #6] MAGIJA

Background

The famous magician Al'Dimi Kartimi needs your help to design the back pattern of his playing cards.

Problem Description

As we all know, the back of a playing card is a rectangle. By drawing the perpendicular bisectors of its two sides, the rectangle can be divided into four equal parts.

Al'Dimi Kartimi first draws the pattern in the upper-left part. The pattern has rr rows and cc columns, and consists of the characters # and .. After finishing, he mirrors this pattern across the vertical midline of the rectangle to draw the upper-right part. Then he mirrors the entire upper half across the horizontal midline to draw the lower half.

After drawing, Al'Dimi Kartimi will intentionally make a small mistake so that he can identify which card back it is. Specifically, he chooses the character in row xx, column yy: if it is #, he changes it to ., otherwise he changes it to #.

Below are three examples of card back patterns (the wrong character is highlighted in gray).

Given the upper-left pattern and x,yx, y, output the full pattern of the entire card back.

Input Format

The first line contains two integers, representing the number of rows rr and the number of columns cc of the upper-left pattern.

Lines 22 to (r+1)(r + 1) each contain a string of length cc. The jj-th character si,js_{i, j} in line (i+1)(i + 1) represents the character in row ii, column jj of the pattern.

Line (r+2)(r + 2) contains two integers, representing the row xx and column yy of the small mistake.

Output Format

Output 2r2r lines, each a string of length 2c2c, representing the full back pattern.

2 2
#.
.#
3 3

#..#
.##.
.#..
#..#
3 3
###
###
###
1 4

###.##
######
######
######
######
######
5 4
#.#.
#.##
#.##
....
.#.#
10 5

#.#..#.#
#.####.#
#.####.#
........
.#.##.#.
.#.##.#.
........
#.####.#
#.####.#
#.#.##.#

Hint

Constraints

For all test cases, it is guaranteed that:

  • 1r,c501 \leq r, c \leq 50.
  • 1x2r1 \leq x \leq 2r, 1y2c1 \leq y \leq 2c.
  • si,j{#,.}s_{i, j} \in \{\texttt \#, \texttt . \}

Notes

This problem is translated from COCI2006-2007 CONTEST #6 T2 MAGIJA

Translated by ChatGPT 5