#P10368. 「LAOI-4」Colors

「LAOI-4」Colors

Background

Do this problem:

Problem Description

Given a string AA of length nn.

  • If Ai1=Ai+1A_{i-1}=A_{i+1}, then AiA_i is called "erasable".

Define one operation as: erase all "erasable" characters in AA.

Please output AA after performing the operation kk times.

Input Format

The first line contains two positive integers T,idT,id, representing the number of test cases and the subtask ID.

For each test case, the first line contains a positive integer nn and an integer kk.

The next line contains a string of length nn.

Output Format

For each test case, output one line with a string representing the answer.

3 0
3 1
aba
5 2
acaca
3 0
abc
aa
aa
abc

Hint

Explanation of the samples:

  • For the 11-st test case, the string is aba\text{aba}, and after one operation it becomes aa\text{aa}.
  • For the 22-nd test case, the string is acaca\text{acaca}, and after one operation it becomes aa\text{aa}, and after two operations it becomes aa\text{aa}.
  • For the 33-rd test case, the string is abc\text{abc}, and after zero operations it is abc\text{abc}.

"This problem uses bundled testdata."

Subtask\text{Subtask} n\sum n \le Special Property Subtask Dependency Total Score
11 10610^6 A\text{A} None 55
22 300300 k300k\le 300 1010
33 10310^3 None 22 1515
44 10610^6 B\text{B} None 1010
55 C\text{C} 44 2020
66 10710^7 None 151\sim5 4040

For 100%100\% of the testdata, 1n1071 \le \sum n \le 10^7, 1T1051 \le T \le 10^5, 0k10180\le k\le 10^{18}, and the strings consist of lowercase letters.

Special property A\text{A}: AA is a permutation of az\text{a}\sim\text{z}.

Special property B\text{B}: i[1,n2],Ai=Ai+2\forall i\in[1,n-2], A_i= A_{i+2}.

Special property C\text{C}: It is guaranteed that each AiA_i can only take two possible values.

Translated by ChatGPT 5