ANARC05I - What is your Logo
Imagine a 2D diagram drawn in the following way: Starting at the origin, you’re given a sequence of letters which is entirely made of the following four letters ’U’, ’D’, ’L’,and ’R’.A ’U’ is an instruction for you to move one unit upward and drawing a segment at the same time. Similarly, ’D’ is for moving down, ’L’ for left, and ’R’ for right.
For example, ﬁgure (a) is drawn by giving the sequence ’UURDLL’ while ﬁgure (b) is the result of ’UURRRDLLLLUURRRDDD’ (in both ﬁgures, the starting point is identiﬁed by a small circle.)
While segments are allowed to intersect, they’re not allowed to overlap. In other words, any two segments will have, at most, one point in common. We’re interested in knowing the number of closed polygons, not containing any lines inside, in such diagrams. Figure (a), has only one closed polygon while ﬁgure (b) has three. Write a program to do exactly that.
Your program will be tested on one or more test cases. Each test case is speciﬁed on a separate line. The diagram is speciﬁed using a sequence made entirely of (U|D|L|R) and terminated by the letter ’Q’. All letters are capital letters. None of the segments in a test case will overlap.
The end of test cases is identiﬁed by the letter ’Q’ on a line by itself.
Length of each sequence is smaller than 1000.
For each test case, write the answer on a separate line.
I'm getting RE. How can I take Input? I do not understand clearly
Last edit: 2017-08-11 07:57:20
Loved it :D
Test Cases are very weak no reason to solve the question!!!!!!
very weak test cases....
English version of the problem says:- NOT FOUND ON THE SERVER...
if u catch the logic then its only programming :)
easy but enjoyed solving it
Awesome problem ...