LCC '23 Contest 1 J4 - Candy Plan

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Kahvei is creating a fun activity for Halloween! His plan consists of an N by N surface filled with candy. Each cell on the surface will contain a specific character. Since Kahvei is broke saving up, all the candy he has is off-brand. These brands are all distinct alphabet characters like a and b.

However, Kahvei realizes that his plan was rotated by K degrees counterclockwise! Since Halloween is approaching and he has no time to rotate his plan, he gives you his plan in hopes that you can help him. He wants you to give him his original plan.

Constraints

1 \le N \le 1000

0 \le K \le 270 where K is a multiple of 90.

Each letter on the plan is guaranteed to be a lowercase character from a to z inclusive.

Input Specification

The first line of input will contain an integer N, followed by integer K.

The next N lines will contain N characters, separated by spaces, representing the candy brand.

Output Specification

The output should consist of N lines with N digits on each line. This will be the rotated array.

Sample Input 1

4 90
a b c d
q w e r
z x c v
a s d f

Sample Output 1

a z q a
s x w b
d c e c
f v r d

Sample Input 2

3 180
n e e
w o l
l a h

Sample Output 2

h a l
l o w
e e n

Comments

There are no comments at the moment.