Logo
(追記) (追記ここまで)

21134번 - Ant Typing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB123575445.763%

문제

Consider a configurable keyboard where keys can be moved about. An ant is walking on the top row of this keyboard and needs to type a numeric string. The ant starts on the leftmost key of the top row, which contains 9ドル$ keys, some permutation of the digits from 1ドル$ to 9ドル$. On a given second, the ant can perform one of three operations:

  1. Stay on that key. The digit corresponding to that key will be entered.
  2. Move one key to the left. This can only happen if the ant is not on the leftmost key.
  3. Move one key to the right. This can only happen if the ant is not on the rightmost key.

Compute the minimum number of seconds needed for the ant to type out the given numeric string, over all possible numeric key permutations.

입력

The single line of input contains a single string $s$ (1ドル \le |s| \le 10^5$) consisting only of numeric digit characters from 1ドル$ to 9ドル$. This is the numeric string that the ant needs to type.

출력

Output a single integer, which is the minimum number of seconds needed for the ant to type out the given numeric string, over all possible numeric key permutations.

제한

예제 입력 1

78432579

예제 출력 1

20

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2020 Southeast USA Regional Programming Contest A번

ICPC > Regionals > North America > Mid-Central Regional > 2020 Mid-Central Regional Programming Contest A번

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 1 G번

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 2 X번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2020 Mid-Atlantic USA Regional Contest C번

ICPC > Regionals > North America > South Central USA Regional > 2020 South Central USA Regional Contest A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /