#TP0000007. Rút gọn tên Apaxia (Apaxiaaaaaaaaaaaans!)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Rút gọn tên Apaxia (Apaxiaaaaaaaaaaaans!)
Apaxiaaaaaaaaaaaans!
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Some names are written with letters repeated several times in a row, making them unnecessarily long. To shorten a name, every maximal consecutive run of identical letters must be replaced by exactly one copy of that letter.
You are given a name consisting of lowercase English letters. Produce its shortened form. Only adjacent equal letters are merged: if the same letter appears again after a different letter, it begins a new run and must be kept.
Input
One line contains the name , without spaces.
Output
Print the shortened name obtained by replacing each consecutive run of equal letters by a single letter.
Subtasks
- Subtask 1 (20 points): ; every character is a lowercase English letter from
atoz. - Subtask 2 (30 points): ; every character is a lowercase English letter from
atoz. - Subtask 3 (50 points): ; every character is a lowercase English letter from
atoz.
Examples
Input
rooobert
Output
robert
Explanation
The name is rooobert. Its consecutive runs, read from left to right, are r, ooo, b, e, r, t. Replace the run ooo with one o; all other runs already have length . Concatenating the remaining letters gives robert, which is the output.