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

6538번 - Run Length Encoding 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB300604018.100%

문제

Your task is to write a program that performs a simple form of run-length encoding, as described by the rules below.

Any sequence of between 2 to 9 identical characters is encoded by two characters. The first character is the length of the sequence, represented by one of the characters 2 through 9. The second character is the value of the repeated character. A sequence of more than 9 identical characters is dealt with by first encoding 9 characters, then the remaining ones.

Any sequence of characters that does not contain consecutive repetitions of any characters is represented by a 1 character followed by the sequence of characters, terminated with another 1. If a 1 appears as part of the sequence, it is escaped with a 1, thus two 1 characters are output.

입력

The input consists of letters (both upper- and lower-case), digits, spaces, and punctuation. Every line is terminated with a newline character and no other characters appear in the input.

출력

Each line in the input is encoded separately as described above. The newline at the end of each line is not encoded, but is passed directly to the output.

제한

예제 입력 1

AAAAAABCCCC
12344

예제 출력 1

6A1B14C
11123124

힌트

출처

Contest > University of Ulm Local Contest > University of Ulm Local Contest 2004 E번

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

출처

대학교 대회

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

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