CF1244F.Chips

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn chips arranged in a circle, numbered from 11 to nn .

Initially each chip has black or white color. Then kk iterations occur. During each iteration the chips change their colors according to the following rules. For each chip ii , three chips are considered: chip ii itself and two its neighbours. If the number of white chips among these three is greater than the number of black chips among these three chips, then the chip ii becomes white. Otherwise, the chip ii becomes black.

Note that for each ii from 22 to (n1)(n - 1) two neighbouring chips have numbers (i1)(i - 1) and (i+1)(i + 1) . The neighbours for the chip i=1i = 1 are nn and 22 . The neighbours of i=ni = n are (n1)(n - 1) and 11 .

The following picture describes one iteration with n=6n = 6 . The chips 11 , 33 and 44 are initially black, and the chips 22 , 55 and 66 are white. After the iteration 22 , 33 and 44 become black, and 11 , 55 and 66 become white.

Your task is to determine the color of each chip after kk iterations.

输入格式

The first line contains two integers nn and kk (3n200000,1k109)(3 \le n \le 200\,000, 1 \le k \le 10^{9}) — the number of chips and the number of iterations, respectively.

The second line contains a string consisting of nn characters "W" and "B". If the ii -th character is "W", then the ii -th chip is white initially. If the ii -th character is "B", then the ii -th chip is black initially.

输出格式

Print a string consisting of nn characters "W" and "B". If after kk iterations the ii -th chip is white, then the ii -th character should be "W". Otherwise the ii -th character should be "B".

输入输出样例

  • 输入#1

    6 1
    BWBBWW
    

    输出#1

    WBBBWW
    
  • 输入#2

    7 3
    WBWBWBW
    

    输出#2

    WWWWWWW
    
  • 输入#3

    6 4
    BWBWBW
    

    输出#3

    BWBWBW
    

说明/提示

The first example is described in the statement.

The second example: "WBWBWBW" \rightarrow "WWBWBWW" \rightarrow "WWWBWWW" \rightarrow "WWWWWWW". So all chips become white.

The third example: "BWBWBW" \rightarrow "WBWBWB" \rightarrow "BWBWBW" \rightarrow "WBWBWB" \rightarrow "BWBWBW".

首页