Logo
(追記) (追記ここまで)

23173번 - Flowerbed Redecoration 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB32221979.167%

문제

Joon-Pyo decorated a flowerbed in front of his home. The flowerbed is in the shape of an $n \times m$ grid, and one flower is planted in each cell. There are 26 colors, one corresponding to each uppercase letter from A to Z. Suddenly, he wanted to redecorate the flowerbed.

The flowerbed is too large to adjust the flowers one by one. He rented some equipment that can lift and rotate a square plot of land with a side length of $d$. He planned the construction in the following order, expecting the flowerbed to be properly redecorated.

  1. Place the equipment so that exactly the flowers in the first $d$ rows and the first $d$ columns are inside.
  2. Rotate the $d \times d$ square inside the equipment 90ドル^\circ$ clockwise. If this square contains flowers from the last $d$ rows and the last $d$ columns, then the construction is finished. Otherwise, if this square does not contain flowers in the last $d$ columns, move the equipment $x$ squares to the right. Otherwise, move the equipment down by $y$ squares and all the way to the left so it contains flowers from the first $d$ columns.
  3. Repeat step 2 until construction is finished.

Note that the equipment will never go out of the flowerbed, as $x,ドル $y,ドル and $d$ are carefully determined before construction begins.

He cannot start construction without knowing the outcome. Write a program that outputs the result.

입력

On the first line, five integers $n,ドル $m,ドル $y,ドル $x,ドル and $d$ are given. (1ドル \leq n \times m \leq 10^6 ,ドル $ 1 \leq y \leq n,ドル $ 1 \leq x \leq m ,ドル $ 1 \leq d \leq \min(n, m),ドル $\boldsymbol{n \equiv d \pmod y},ドル $\boldsymbol{m \equiv d \pmod x}$).

Each of the next $n$ lines contains exactly $m$ uppercase letters, the current flowerbed.

출력

Output $n$ lines, each containing $m$ uppercase letters, the flowerbed after the planned construction.

제한

예제 입력 1

4 4 1 1 2
AAAA
BBBB
AAAA
BBBB

예제 출력 1

BAAA
ABBB
BAAA
BBBA

예제 입력 2

6 5 1 2 3
RBRCY
YBPBR
PBRCY
CYPBR
PBRCY
CYPBR

예제 출력 2

PYRBR
CRCBB
PPBPY
CRCYB
YRBCY
PYRBR

노트

In the first example, the flowerbed changes as follows:

출처

University > KAIST > KAIST ICPC Mock Competition > 2021 KAIST 11th ICPC Mock Competition D번

Contest > Open Cup > 2021/2022 Season > Stage 4: Grand Prix of Korea D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /