RubrikOA #5
Word Compression (Remove k Consecutive Equal Characters)
估计中等可在线判题
Repeatedly delete any group of exactly K consecutive identical characters from the word until no further deletion is possible; the statement guarantees that at least one character remains at the end and states that the final result is unique.
输入格式
One line containing a lowercase ASCII word word and an integer K. This site adds 2≤K≤200000 and 2≤|word|≤200000. The input must be such that the result after compressing by the rules is non-empty (consistent with the original problem's guarantee).
输出格式
Output the word that remains at the end.
样例 1
输入:
abbbaac 3
输出:
c
样例 2
输入:
aaab 3
输出:
b
样例 3
输入:
abcd 2
输出:
abcd