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

20967번 - Uddered but not Herd 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB166897256.693%

문제

A little known fact about cows is that they have their own version of the alphabet, the "cowphabet". It consists of the 26 letters 'a' through 'z', but when a cow speaks the cowphabet, she lists these letters in a specific ordering that might be different from the order 'abcdefghijklmnopqrstuvwxyz' we are used to hearing.

To pass the time, Bessie's cousin Mildred has been humming the cowphabet over and over again, and Farmer Nhoj is curious how many times she's hummed it.

Given a lowercase string of letters that Farmer Nhoj has heard Mildred say, compute the minimum number of times Mildred must have hummed the entire cowphabet in order for Farmer Nhoj to have heard the given string. Farmer Nhoj isn't always paying attention to what Mildred hums, and so he might have missed some of the letters that Mildred has hummed. The string you are told consists of just the letters that he remembers hearing.

입력

The only line of input contains the string of lowercase letters that Farmer Nhoj heard Mildred say. This string has length at least 1ドル$ and at most 10ドル^5$.

출력

Print the minimum number of times Mildred must have hummed the entire cowphabet.

제한

  • In test cases 1-5, Farmer Nhoj only heard letters that appear in Mildred's or Bessie's names.
  • In test cases 6-16, Farmer Nhoj never heard any of the letters that appear in Mildred's name.

예제 입력 1

mildredree

예제 출력 1

3

힌트

Mildred must have hummed the cowphabet at least three times. It is possible for Mildred to have only hummed the cowphabet three times if the cowphabet starts with "mildre" and Farmer Nhoj heard the letters in uppercase as denoted below.

MILDREabcfghjknopqstuvwxyz
milDREabcfghjknopqstuvwxyz
mildrEabcfghjknopqstuvwxyz

출처

Olympiad > USA Computing Olympiad > 2020-2021 Season > USACO 2021 January Contest > Gold 1번

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

출처

대학교 대회

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

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