Submit | All submissions | Best solutions | Back to list |
SIGNPOST - Signpost reading |
Examples
Input: The hero was deep inside the dragon's lair. But he was not afraid; he knew what was coming. Each dragon layer has some crossroads. At each crossroad, one can go either left or right. At each crossroad there is a signpost, indicating what is to the left, and what is to the right, always in the same format. One direction leads to the dragon. If the hero, in full armour, went into the dragon's bedroom, he would surely wake him up and become breakfast in bed. So, the hero will definitely choose the other option. The hero always reads this signpost into a single line, by itself. Oh, here comes the first crossroads, thought the hero to himself. Left to dragon. Right to princess. Oh no, what is this sorcery!? What heroes don't know, is that the signposts are cursed. Whoever reads one, forgets which of the two options he definitely didn't want to pick. So the hero needs your help - Every time he manages to read a signpost, tell him where he needs to go. Output: Right, to the princess!
Input: The story contains at most 100 lines, none of which are over 100 characters long. The signposts are always read into a single, separate line, and strictly follow the following format: Left to x. Right to y. Where x,y are non-empty strings made up of letters of the english alphabet, one of them is 'dragon', and the other is NOT 'dragon'. This line has no missing, or extra, spaces. Notice that the above example is not a valid signpost, as it violates 'one of x,y is dragon'. Often, heroes just mentally prepare for the inevitable signpost they will face. Right to dragon. Left to princess. Hm, on a real signpost the directions would probably be the other way around, thought the hero. Wait, what is this before me!? Left to dragon. Right to goodluck. Left to youwillneedit. Right to dragon. What is happening!? Where should I go??? Left to havefun. Right to dragon. Output: Right, to the goodluck! Left, to the youwillneedit! Left, to the havefun!
Added by: | Hodobox |
Date: | 2018-03-22 |
Time limit: | 0.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | own problem |
hide comments
2018-10-05 02:51:44 :D
It's one of those "read the description REALLY carefully" problems. Nice change of pace from other tasks on SPOJ. |
|
2018-04-03 07:13:21 him0727
<snip spoilers> Thanks, finally accepted. Interesting problem. Last edit: 2018-04-03 21:06:33 |
|
2018-03-31 11:29:09 Simes
lol. I can't believe how many attempts this took me. Not as simple as it first appears. |
|
2018-03-23 06:59:40
Considering psetter's experience, I'd assume we should follow anything that isn't a lowercase dragon. But I get WA too with code too simple to break. I sure hope Hodobox isn't trolling us here, solving string problems on online judges with unknown input format and no feedback is frustrating enough. @nadstratosfer (last non-disqualified submission): there should be no output for Left to dragon. Right to a_b_c. Edit: Got AC after fixing the _ problem following an additional WA for not trusting Hodobox on the lowercase dragon. No trolling! Thanks. Last edit: 2018-03-23 19:25:10 |
|
2018-03-23 03:36:37 [Rampage] Blue.Mary
If the input line is "Left to DRAGON. Right to dragon." (without quotes) What's the expected output? No output at all or "Left, to the DRAGON!" ? Or do I miss something in the problem description? @Blue.Mary: indeed, 'Left, to the DRAGON!'. Last edit: 2022-06-24 12:31:34 |