10211_HiddenPassword

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

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

Pro.ID

10211

Title

Hidden Password

Title链接

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

AC

2

Submit

3

Ratio

66.67%

时间&空间限制

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

    Sometimes the programmers have very strange ways of hiding their passwords. Billy "Hacker" Geits chooses a string S composed of L (5 ≤ L ≤ 100,000) lowercase letters ('a'..'z') with length L. Then he makes and sorts all L-1 one-letter left cyclic shifts of the string. He then takes as a password one prefix of the lexicographically first of the obtained strings (including S).

    For example consider the string "alabala". The sorted cyclic one-letter left shifts (including the initial string) are:

    aalabal
    abalaal
    alaalab
    alabala
    balaala
    laalaba
    labalaa

    Lexicographically, first string is 'aalabal'. The first letter of this string ('a') is the 'a' that was in position 6 in the initial string (counting the first letter in the string as position 0).

    Write a program that, for given string S, finds the start position of the first letter of the sorted list of cyclic shifts of the string. If the first element appears more than once in the sorted list, then the program should output the smallest possible initial position.

    输入

    Line 1:     A single integer: L

    Line 2..?:     All L characters of the the string S, broken across lines such that each line has 72 characters except the last one, which might have fewer.

    输出

    Description

    Sometimes the programmers have very strange ways of hiding their passwords. Billy "Hacker" Geits chooses a string S composed of L (5 ≤ L ≤ 100,000) lowercase letters ('a'..'z') with length L. Then he makes and sorts all L-1 one-letter left cyclic shifts of the string. He then takes as a password one prefix of the lexicographically first of the obtained strings (including S).

    For example consider the string "alabala". The sorted cyclic one-letter left shifts (including the initial string) are:

    aalabal
    abalaal
    alaalab
    alabala
    balaala
    laalaba
    labalaa

    Lexicographically, first string is 'aalabal'. The first letter of this string ('a') is the 'a' that was in position 6 in the initial string (counting the first letter in the string as position 0).

    Write a program that, for given string S, finds the start position of the first letter of the sorted list of cyclic shifts of the string. If the first element appears more than once in the sorted list, then the program should output the smallest possible initial position.

    Input

    Line 1:     A single integer: L

    Line 2..?:     All L characters of the the string S, broken across lines such that each line has 72 characters except the last one, which might have fewer.

    Output

    Line 1:   A single integer that is the start position of the first letter, as described above.

    Sample Input

    7
    alabala

    Sample Output

    6

    Source

    样例输入

    7
    alabala

    样例输出

    6

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部