#P15413. [CCC 2019 J4/S1] Flipper 翻转

[CCC 2019 J4/S1] Flipper 翻转

Problem Description

While waiting at the optometrist, you try to pass the time. You notice a grid containing four numbers:

11 22
33 44

You see many mirrors and lenses, so you wonder what happens if you flip this grid horizontally or vertically.

  • One “horizontal flip” (flip along the horizontal center line) becomes:
33 44
11 22
  • One “vertical flip” (flip along the vertical center line) becomes:
22 11
44 33

Your task is: after performing a sequence of horizontal and vertical flips, determine the final arrangement of the grid.

Input Format

The input is a single string, with length at least 11 character and at most 1,000,0001,000,000 characters.

Each character is:

  • H — represents one horizontal flip.
  • V — represents one vertical flip.

For 88 out of 1515 points, the input length is at most 10001000 characters.

Output Format

Output the final arrangement of the grid.

Print two lines, each with two integers, separated by one space.

HV
4 3
2 1
VVHH
1 2
3 4

Hint

Translation source: GPT 5.2.

Translated by ChatGPT 5