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


  • 0
    MonkeyKang16  commented on Nov. 22, 2025, 5:14 p.m.

    can someone help me. i am getting a keyerror in batch 2 ane a tle smt in batch 3. https://dmoj.ca/submission/7423820


  • 0
    EtherealComet  commented on Nov. 4, 2025, 7:04 a.m.

    only if all j4s were like this...


    • 0
      Narcariel  commented on Nov. 4, 2025, 5:30 p.m.

      Scrubs like me can dream :)


      • -1
        EtherealComet  commented on Nov. 5, 2025, 2:19 a.m.

        dont mind me if i ask, but is your profile picture a combination of big chungus and quagmire?


  • -6
    Crakxinator  commented on Jan. 7, 2025, 12:16 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 4
      Sponetics  commented on Jan. 7, 2025, 4:17 p.m.

      It's a 3 pointer for a reason


  • 6
    Excalibur  commented on March 23, 2023, 3:41 p.m. edited

    wow this problem is easier tha i thought


    • 0
      doggykev  commented on Feb. 7, 2024, 11:18 p.m.

      Too ez to be a S1


    • 1
      Viv_CCGS  commented on Jan. 22, 2024, 11:22 a.m.

      Easiest S1 in a while. Brute forcing the whole problem pulls through. There is a smart way involving cancelling the Vs and the Hs out. The time and memory limit is sufficient for either approach.


    • 2
      WenhanZhang  commented on Oct. 30, 2023, 2:26 a.m.

      it is probably the easiest question in J4, S1 of CCC


  • 5
    960t  commented on Feb. 8, 2023, 12:48 a.m. edited

    i finished the problem with 0.01 seconds left lol


  • 6
    MrBloc01  commented on Jan. 2, 2023, 7:01 p.m. edited

    why is this a j4/s1?


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

    2 verticals cancel out