시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB74443667.925%

문제

Andrei is an adventurer who tries to find a treasure full of gold coins. When he arrives at the last clue, which will tell him where the treasure is, he sees that on the clue there are two numbers, N and K, and a string of N lowercase English letters. Andrei should take the current string and should eliminate the first sequence of exactly K identical letters which appear on consecutive positions. He will repeat this process until there will be no sequence which has K consecutive identical letters.

Andrei asks you to solve this problem as soon as possible so that he will be the first who discovers the treasure.

Find the final string after you successively eliminate the first sequence of K identical letters which appear on consecutive positions, until there is no such sequence left.

입력

The first line of the input contains two integers, N, representing the number of characters of the string, and K, representing the lenght of a sequence of identical characters.

The second line of the input contains the string of N lowercase English letters.

출력

The first line of the output contains a string of lowercase English letters, the string which will be obtained after all the possible eliminations are made.

제한

  • 2 ≤ K ≤ N ≤ 200,000
  • The initial string contains only lowercase English letters
  • It is guaranteed that the final string is not empty!

서브태스크

번호배점제한
135

N, K ≤ 1,000

265

N, K ≤ 200,000

예제 입력 1

5 2
abbac

예제 출력 1

c
  • The initial string : abbac
  • The string after the first elimination : aac
  • The string after the second elimination : c

예제 입력 2

12 3
aabbbaabbaac

예제 출력 2

abbaac
  • The initial string : aabbbaabbaac
  • The string after the first elimination : aaaabbaac
  • The string after the second elimination : abbaac

채점 및 기타 정보

  • 예제는 채점하지 않는다.