-->
当前位置:首页 > 题库

PROGRAMMING:The best team

Luz5年前 (2021-05-10)题库441
With the new hero card, Xiao Li happily prepares to PK with his classmates.
The rules of their game are very simple. Both sides wind their cards into a circle, and then specify a starting point. From the card, they take it back clockwise. Who takes out the string with smaller dictionary order (from left to right, when they encounter the first different character for comparison, the comparison rule is a < B <... < z) who will win. For specific rules, please refer to the example. Although Xiao Li's card is very good now, can you help him quickly calculate the starting position so that he can send out the strongest team.
###Input format:
The first line, N, indicates that there are N cards.
The second line contains n lowercase letters separated by a space, indicating the starting sequence of a given round of cards.
###Output format:
Only one integer can get the starting position of the minimum lexicographic string. If the string starting from multiple positions is the same, the smallest position will be output, and the first position will start from 1.
###Input example:
```in
four
b c a b
```
###Output example:
```out
three
```
[example description]
The four positions are bcab, Cabb, abbc and BBCA. Obviously, the minimum position is 3.
[data scale]
30% of data, 1 < = n < = 10
60% of data, 1 < = n < = 1000
100% data, 1 < = n < = 30000







answer:If there is no answer, please comment