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

26020번 - Jesting Jabberwocky 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB53373472.340%

문제

Figure J.1: In Sample 1, Alice has to move at least two cards to sort her hand.

The famous card game manufacturer Greatest Cards Production Company (GCPC) has just created the brand new card game Jabberwocky. In this game, everyone gets the same amount of cards -- which might be quite a lot -- and each card belongs to one of four different suits: hearts, diamonds, clubs, or spades.

As huge card game nerds, Alice and her friends are very hyped about meeting up and trying out the card game everybody seems to talk about these days. Due to a traffic jam, Alice is a bit late to the party and her friends are impatiently waiting for her. They have already distributed all cards and everybody is ready to go, except for Alice. She has just picked up her cards and insists on sorting them by suit first. For that, she repeatedly picks one card from her hand and inserts it somewhere else until her cards are grouped by suit. Her friends are getting increasingly annoyed with Alice and she wants to sort her cards as quickly as possible. How many cards does Alice need to move before they can start playing?

입력

The input consists of:

  • One line with a string $s$ (1ドル\leq|s|\leq 10^5$), representing the suits of Alice's cards as they are initially ordered. The string consists of the characters h, d, c, and s (hearts, diamonds, clubs and spades).

출력

Output a single integer, the minimum number of cards Alice has to move in order to sort the cards by suit.

제한

예제 입력 1

hccdhcd

예제 출력 1

2

예제 입력 2

cchhdshcdshdcsh

예제 출력 2

7

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2022 J번

  • 문제를 만든 사람: Wendy Yi
(追記) (追記ここまで)

출처

대학교 대회

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

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