CCC '05 J3 - Returning Home

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2005 Stage 1, Junior #3

Jane's family has just moved to a new city and today is her first day of school. She has a list of instructions for walking from her home to the school. Each instruction describes a turn she must make. For example, the list

R
QUEEN
R
FOURTH
R
SCHOOL

means that she must turn right onto Queen Street, then turn right onto Fourth Street, then finally turn right into the school. Your task is to write a computer program which will create instructions for walking in the opposite direction: from her school to her home.

The input and output for your program will be formatted like the samples below. You may assume that Jane's list contains at least two but at most five instructions, and you may assume that each line contains at most 10 characters, all of them capital letters. The last instruction will always be a turn into the SCHOOL.

Sample Input 1

R
QUEEN
R
FOURTH
R
SCHOOL

Sample Output 1

Turn LEFT onto FOURTH street.
Turn LEFT onto QUEEN street.
Turn LEFT into your HOME.

Sample Input 2

L
MAIN
R
SCHOOL

Sample Output 2

Turn LEFT onto MAIN street.
Turn RIGHT into your HOME.

Comments


  • 1
    YeetusPoteetus2  commented on Jan. 30, 2023, 12:53 p.m.

    my program works when I am testing it with the samples, however when I submit it, it does not fully print the answer. instead it does this "Test case #1:
    WA [0.030s, 10.16 MB] (0/10)

    Your output (clipped) Turn RIGHT onto D street. Turn RIGHT onto C street. Turn RIGHT o

    I do not understand what happened.


    • 0
      dnialh_  commented on Jan. 31, 2023, 7:30 a.m.

      DMOJ only shows a clipped version of your output on the site (to make sure nothing major is going wrong). The full version of your output is being seen on the server (and is being judges as WA).


  • 0
    BaconBest  commented on May 16, 2021, 12:58 a.m.

    how do you make the street names flip over?


    • 6
      Azdera  commented on July 9, 2021, 12:32 a.m.

      Check if they are L or R and switch correspondingly.


  • 1
    Arihan10  commented on Jan. 18, 2019, 2:24 a.m. edit 2

    Shouldn't Sample Input 2 be:

    Turn RIGHT onto MAIN street.
    Turn LEFT into your HOME.

    Since R = L and L = R?

    EDIT: I realized my mistake.


    • -57
      magicalsoup  commented on Jan. 18, 2019, 2:32 a.m.

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


      • 10
        Haoyun  commented on Jan. 18, 2022, 6:42 p.m.

        Don't be such a meany


      • 22
        Arihan10  commented on Jan. 18, 2019, 2:50 p.m.

        No, sorry, I now realize that the Sample is correct.


  • -11
    raggarwal  commented on Nov. 26, 2014, 3:34 p.m.

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


    • 31
      FatalEagle  commented on Nov. 26, 2014, 6:55 p.m.

      It will always end with SCHOOL.