Editorial for CCC '19 S1 - Flipper
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Create a 2D array of size .
Let:
A[0][0] = 1
,
A[0][1] = 2
,
A[1][0] = 3
, and
A[1][1] = 4
as stated in the problem.
To reflect horizontally, swap A[0][0]
with A[1][0]
and swap A[0][1]
with A[1][1]
.
To reflect vertically, swap A[0][0]
with A[0][1]
and swap A[1][0]
with A[1][1]
.
For each character in the line of input, perform a horizontal reflection if the character is H
and perform a vertical reflection if the character is V
.
This solution passes both subtasks.
Then output the 2D array as specified.
Time complexity:
Comments
But the operations are commutative so you can just count the number of flips and mod 2. At most you'll need to do 1 V and 1 H.
This comment is hidden due to too much negative feedback. Show it anyway.
It's still because you need to read the full input.