CCC '19 S1 - Flipper

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type
Canadian Computing Competition: 2019 Stage 1, Junior #4, Senior #1

You are trying to pass the time while at the optometrist. You notice there is a grid of four numbers:

\displaystyle \begin{array}{|c|c|}\hline
1 & 2 \\\hline
3 & 4 \\\hline
\end{array}

You see lots of mirrors and lenses at the optometrist, and wonder how flipping the grid horizontally or vertically would change the grid.

Specifically, a "horizontal" flip (across the horizontal centre line) would take the original grid of four numbers and result in:

\displaystyle \begin{array}{|c|c|}\hline
3 & 4 \\\hline
1 & 2 \\\hline
\end{array}

A "vertical" flip (across the vertical centre line) would take the original grid of four numbers and result in:

\displaystyle \begin{array}{|c|c|}\hline
2 & 1 \\\hline
4 & 3 \\\hline
\end{array}

Your task is to determine the final orientation of the numbers in the grid after a sequence of horizontal and vertical flips.

Input Specification

The input consists of one line, composed of a sequence of at least one and at most 1\,000\,000 characters. Each character is either H, representing a horizontal flip, or V, representing a vertical flip.

For 8 of the 15 available marks, there will be at most 1\,000 characters in the input.

Output Specification

Output the final orientation of the four numbers. Specifically, each of the two lines of output will contain two integers, separated by one space.

Sample Input 1

HV

Sample Output 1

4 3
2 1

Sample Input 2

VVHH

Sample Output 2

1 2
3 4

Comments


  • 1
    qiao_yun20060930  commented on May 4, 2021, 10:55 p.m.

    here: https://dmoj.ca/submission/3607125 why i got error It passes on my local ide though


    • 0
      Badmode  commented on May 5, 2021, 1:15 a.m.

      You got Horizontal and Vertical flips mixed up.


  • 1
    JeremyYang  commented on April 30, 2021, 6:29 p.m.

    2 verticals cancel out


  • 3
    ayay9  commented on Feb. 5, 2021, 10:43 p.m.

    When you brute force a S1 in 5 minutes. :poggers:


  • -1
    ASDAN149A  commented on Jan. 16, 2021, 2:48 a.m. edited

    how to delete a comment


    • 1
      OneYearOld  commented on Jan. 16, 2021, 11:22 a.m.

      You can't do so, unless you ask an administrator.


  • 0
    mahes0640  commented on Jan. 6, 2021, 2:03 p.m.

    Can anyone tell me how I can fix my whitespace?


    • 0
      773175  commented on Jan. 12, 2021, 6:16 a.m.

      ur problem is that ur if conditionals need to reversed. Not a whitespace prblem


      • 1
        mahes0640  commented on Jan. 16, 2021, 5:57 p.m.

        Thank you so much


  • -5
    python6645  commented on Nov. 29, 2020, 4:26 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • -2
      Jaazib  commented on Jan. 6, 2021, 1:15 p.m.

      its pretty easy, but I think its too low