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

21956번 - Treasure 서브태스크다국어

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

문제

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

힌트

출처

Contest > infO(1) Cup > infO(1) Cup 2019 National Round 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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