COCI '06 Contest 5 #1 Trik

View as PDF

Submit solution


Points: 3
Time limit: 1.0s
Memory limit: 32M

Problem type

Jealous of Mirko's position as head of the village, Borko stormed into his tent and tried to demonstrate Mirko's incompetence for leadership with a trick.

Borko puts three opaque cups onto the table next to each other (opening facing down) and a small ball under the leftmost cup. He then swaps two cups in one of three possible ways a number of times. Mirko has to tell which cup the ball ends up under.

Wise Mirko grins with his arms crossed while Borko struggles to move the cups faster and faster. What Borko does not know is that programmers in the back are recording all his moves and will use a simple program to determine where the ball is. Write that program.

Input Specification

The first and only line contains a string of at most 50 characters, Borko's moves.

Each of the characters is A, B or C.

Output Specification

Output the index of the cup under which the ball is: 1 if it is under the left cup, 2 if it is under the middle cup or 3 if it is under the right cup.

Sample Input 1

AB

Sample Output 1

3

Sample Input 2

CBABCACCC

Sample Output 2

1

Comments


  • -5
    maksim  commented on Aug. 9, 2024, 8:36 a.m. edited

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


  • 2
    JustChaz  commented on March 11, 2022, 6:39 p.m. edited

    I'm at a loss, I'm unsrue what I am doing wrong. It appears, when having 'AA' the Ball stays in locations 2, and does not go back to locations 1 on the 2nd A [Iteration]

    When location is called, should be 1, but outputs 2. Please advise. Here is my Sub {https://dmoj.ca/submission/4408870}


    • 4
      Spitfire720  commented on March 11, 2022, 8:27 p.m.

      ball_location == 1


      • 2
        JustChaz  commented on March 12, 2022, 4:43 p.m.

        Much Appreciated! So many '=' Guess I just kept overlooking it, felt defeated and it was the last thing I wanted to do before I slept, but failed haha. Too tired and haste-y.