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

15073번 - Red Rover 다국어

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

문제

One of our older Mars Rovers has nearly completed its tour of duty and is awaiting instructions for one last mission to explore the Martian surface. The survey team has picked a route and has entrusted you with the job of transmitting the final set of instructions to the rover. This route is simply a sequence of moves in the cardinal directions: North, South, East, and West. These instructions can be sent using a string of corresponding characters: N, S, E, and W. However, receiving the signal drains the rover’s power supply, which is already dangerously low. Fortunately, the rover’s creators built in the ability for you to optionally define a single “macro" that can be used if the route has a lot of repetition. More concretely, to send a message with a macro, two strings are sent. The first is over the characters {N,S,E,W,M} and the second is over {N,S,E,W}. The first string represents a sequence of moves and calls to a macro (M), while the second string determines what the macro expands out to. For example:

WNMWMME
EEN

is an encoding of

WNEENWEENEENE

Notice that the version with macros requires only 10 characters, whereas the original requires 13.

Given a route, determine the minimum number of characters needed to transmit it to the rover.

입력

Input consists of a single line containing a string made up of the letters N, S, E, and W representing the route to transmit to the rover. The maximum length of the string is 100.

출력

Display the minimum number of characters needed to encode the route.

제한

예제 입력 1

WNEENWEENEENE

예제 출력 1

10

예제 입력 2

NSEW

예제 출력 2

4

예제 입력 3

EEEEEEEEE

예제 출력 3

6

힌트

출처

ICPC > Regionals > North America > East Central North America Regional > 2016 East Central Regional Contest E번

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

출처

대학교 대회

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

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