B: Mirror Images
https://open.kattis.com/problems/mirror
We need to reflect a matrix twice: once left-to-right and once top-to-bottom.
To reflect left-to-right, M[i][j]
becomes M[i][c-1-j]
.
To reflect top-to-bottom, M[i][j]
becomes M[r-1-i][j]
.
So, we want to translate all elements in the input matrix M[i][j]
to M[r-1-i][c-1-j]
.
We can do this while reading input:
Last updated