22248_What'syourLogo_

2022-5-16 18:21| 发布者: Hocassian| 查看: 37| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506234536500-Problem List-采集的数据-后羿采集器.html

Pro.ID

22248

Title

What's your Logo?

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22248

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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, figure (a) is drawn by giving the sequence 'UURDLL' while figure (b) is the result of  'UURRRDLLLLUURRRDDD' (in both figures, the starting point is identified 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 figure (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 specified on a separate line. The diagram is specified 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 identified by the letter 'Q' on a line by itself.

    输出

    Description

    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, figure (a) is drawn by giving the sequence 'UURDLL' while figure (b) is the result of  'UURRRDLLLLUURRRDDD' (in both figures, the starting point is identified 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 figure (b) has three. Write a program to do exactly that.

    Input

    Your program will be tested on one or more test cases. Each test case is specified on a separate line. The diagram is specified 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 identified by the letter 'Q' on a line by itself.

    Output

    For each test case, write the answer on a separate line.

    Sample Input

    UURDLLQ
    UURRRDLLLLUURRRDDDQ
    Q

    Sample Output

    1
    3

    Source

    样例输入

    UURDLLQ
    UURRRDLLLLUURRRDDDQ
    Q

    样例输出

    1
    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部