問題一覧 > 通常問題

No.1469 programing

レベル : / AI推定難易度 : 111 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 309
作問者 : harurun / テスター : 👑 hamamu nok0
お気に入りにしたユーザー ProblemId : 6220 / 自分の提出
問題文最終更新日: 2021-04-04 16:27:21
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 290 (順位表) の他の問題:

Problem Statement

harurun is bad at English and writes programming as programing.

We call this way of writing, in which $2$ consecutive identical characters are written as $1$ character, $harurun$ notation.

You are given $1$ string $S$. Output it in $harurun$ notation.

However, a string in which $3$ or more identical characters are consecutive is never given.


The formal problem statement is as follows.

You are given a string $S$.

Output the string $S$ after performing the following operation as many times as possible.

  • When $2$ adjacent characters are the same, delete one of them.

However, a string in which $3$ or more identical characters are consecutive, such as abbb, is not given.


(AC has been confirmed with Python3, PyPy3, C, C++17(1z), Java15, Javascript, and Rust, but slow languages such as Bash may not be able to get AC.)

Input

$S$

The string $S$ is given on line $1$.

Constraints

  • $S_i (1≤i≤|S|)$ is a lowercase English letter.

  • $1≤|S|≤5\times10^6$

  • When $S_i$ and $S_{i+1}$ are the same character, $S_{i+1}$ and $S_{i+2}$ are different characters. $(1≤i<|S|-1)$

  • ($S_{i}$ denotes the $i$-th character of $S$, and $|S|$ denotes the length of $S$.)

Output

Output the answer on one line.

Print a newline at the end.

Sample

Sample 1
Input
programming
Output
programing

You only need to delete 1 of the consecutive m's.

Sample 2
Input
aabbccb
Output
abcb

Strings that are not real English words may also be given.

Sample 3
Input
abcdefghijklmnopqrstuvwxyz
Output
abcdefghijklmnopqrstuvwxyz

There may be nothing to delete.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。