21268_ShapeNumber

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

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

Pro.ID

21268

Title

Shape Number

Title链接

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

AC

1

Submit

4

Ratio

25.00%

时间&空间限制

  • Time Limit: 10000/5000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others)
  • 描述

    In computer vision, a chain code is a sequence of numbers representing directions when following the contour of an object. For example, the following figure shows the contour represented by the chain code 22234446466001207560 (starting at the upper-left corner).


    Two chain codes may represent the same shape if the shape has been rotated, or if a different starting point is chosen for the contour. To normalize the code for rotation, we can compute the first difference of the chain code instead. The first difference is obtained by counting the number of direction changes in counterclockwise direction between consecutive elements in the chain code (the last element is consecutive with the first one). In the above code, the first difference is

    00110026202011676122

    Finally, to normalize for the starting point, we consider all cyclic rotations of the first difference and choose among them the lexicographically smallest such code. The resulting code is called the shape number.

    00110026202011676122
    01100262020116761220
    11002620201167612200
    ...
    20011002620201167612

    In this case, 00110026202011676122 is the shape number of the shape above.

    输入

    The input consists of a number of cases. The input of each case is given in one line, consisting of a chain code of a shape. The length of the chain code is at most 300,000, and all digits in the code are between 0 and 7 inclusive. The contour may intersect itself and needs not trace back to the starting point.

    输出

    Description

    In computer vision, a chain code is a sequence of numbers representing directions when following the contour of an object. For example, the following figure shows the contour represented by the chain code 22234446466001207560 (starting at the upper-left corner).


    Two chain codes may represent the same shape if the shape has been rotated, or if a different starting point is chosen for the contour. To normalize the code for rotation, we can compute the first difference of the chain code instead. The first difference is obtained by counting the number of direction changes in counterclockwise direction between consecutive elements in the chain code (the last element is consecutive with the first one). In the above code, the first difference is

    00110026202011676122

    Finally, to normalize for the starting point, we consider all cyclic rotations of the first difference and choose among them the lexicographically smallest such code. The resulting code is called the shape number.

    00110026202011676122
    01100262020116761220
    11002620201167612200
    ...
    20011002620201167612

    In this case, 00110026202011676122 is the shape number of the shape above.

    Input

    The input consists of a number of cases. The input of each case is given in one line, consisting of a chain code of a shape. The length of the chain code is at most 300,000, and all digits in the code are between 0 and 7 inclusive. The contour may intersect itself and needs not trace back to the starting point.

    Output

    For each case, print the resulting shape number after the normalizations discussed above are performed.

    Sample Input

    22234446466001207560
    12075602223444646600

    Sample Output

    00110026202011676122
    00110026202011676122

    Source

    样例输入

    22234446466001207560
    12075602223444646600

    样例输出

    00110026202011676122
    00110026202011676122

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部