102901: [Atcoder]ABC290 B - Qual B

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:2 Solved:0

Description

Score : $200$ points

Problem Statement

There were $N$ contestants in the qualification round of a programming contest. All contestants got distinct ranks.
You are given a length-$N$ string $S$, which represents whether the contestants want to participate in the final round or not. Specifically,

  • if the $i$-th character of $S$ is o, the contestant ranked $i$-th in the qualification wants to participate in the final;
  • if the $i$-th character of $S$ is x, the contestant ranked $i$-th in the qualification does not want to participate in the final.

Among those who want to participate in the final, $K$ contestants with the smallest ranks advance to the final.

Print a string $T$ of length $N$ that satisfies the following conditions:

  • if the contestant ranked $i$-th in the qualification advances to the final, the $i$-th character of $T$ is o;
  • if the contestant ranked $i$-th in the qualification does not advance to the final, the $i$-th character of $T$ is x.

Constraints

  • $N$ and $K$ are integers.
  • $1 \le K \le N \le 100$
  • $S$ is a string of length $N$ consisting of o and x.
  • $S$ has at least $K$ o's.

Input

The input is given from Standard Input in the following format:

$N$ $K$
$S$

Output

Print the answer.


Sample Input 1

10 3
oxxoxooxox

Sample Output 1

oxxoxoxxxx

In this input, $N=10$ people took part in the qualification round, and $K=3$ of them advance to the final.

  • The participant who ranked $1$-st in the qualification wants to participate in the final, so the participant advances to the final. $1$ participant has advanced so far.
  • The participants who ranked $2$-nd and $3$-rd in the qualification do not want to participate in the final, so the participants do not advance to the final.
  • The participant who ranked $4$-th in the qualification wants to participate in the final, so the participant advances to the final. $2$ participants have advanced so far.
  • The participants who ranked $5$-th in the qualification does not want to participate in the final, so the participant does not advance to the final.
  • The participant who ranked $6$-th in the qualification wants to participate in the final, so the participant advances to the final. $3$ participants have advanced so far.
  • Now that $3$ people have advanced to the final, no participants ranked $7$-th or lower advance to the final.

Input

题意翻译

#### 题目描述 在一场比赛中,有 $N$ 个参赛者,所有参赛者都有一个排名。 有一个长度为 $N$ 的字符串 $S$,代表参赛者是否想参加决赛。 - 如果第 $i$ 个字符为 `o`,表示排名第 $i$ 的参赛者要参加决赛; - 如果第 $i$ 个字符为 `x`,表示排名第 $i$ 的参赛者不要参加决赛; 在要参加决赛的参赛者中,排名前 $K$ 的可以参加决赛。 输出满足以下条件的长度为 $N$ 的字符串 $T$: - 如果第 $i$ 名参赛者可以参加决赛,则第 $i$ 个字符为 `o`; - 如果第 $i$ 名参赛者不可以参加决赛,则第 $i$ 个字符为 `x`; #### 输入格式 输入以以下格式: >$N\ K$ > >$S$ #### 输出格式 输出答案。 #### 说明/提示 - $N,K$ 都是整数 - $1\leq K \leq N \leq100$ - $S$ 是一个长度为 $N$ 并且由 `o` 和 `x` 组成的字符串 - $S$ 至少有 $K$ 个 `o`

Output

分数:200分

问题描述

在一个编程竞赛的资格赛中有N名选手。所有选手的排名都是不同的。

  • 如果字符串S的第i个字符是o,那么在资格赛中排名i的选手想要参加决赛;
  • 如果字符串S的第i个字符是x,那么在资格赛中排名i的选手不想参加决赛。

在想要参加决赛的选手中,排名最小的K名选手可以进入决赛。

输出一个长度为N的字符串T,满足以下条件:

  • 如果资格赛中排名i的选手进入决赛,那么字符串T的第i个字符是o
  • 如果资格赛中排名i的选手没有进入决赛,那么字符串T的第i个字符是x

约束

  • N和K是整数。
  • 1≤K≤N≤100
  • S是一个长度为N的字符串,由ox组成。
  • S至少有K个o

输入

输入将从标准输入中以以下格式给出:

$N$ $K$
$S$

输出

输出答案。


样例输入1

10 3
oxxoxooxox

样例输出1

oxxoxoxxxx

在这个输入中,有10名选手参加了资格赛,其中3名选手进入决赛。

  • 在资格赛中排名1的选手想要参加决赛,所以该选手进入了决赛。到目前为止有1名选手进入了决赛。
  • 在资格赛中排名2和3的选手不想参加决赛,所以这些选手没有进入决赛。
  • 在资格赛中排名4的选手想要参加决赛,所以该选手进入了决赛。到目前为止有2名选手进入了决赛。
  • 在资格赛中排名5的选手不想参加决赛,所以该选手没有进入决赛。
  • 在资格赛中排名6的选手想要参加决赛,所以该选手进入了决赛。到目前为止有3名选手进入了决赛。
  • 现在已经有3人进入了决赛,排名7或更低的选手都没有进入决赛。

加入题单

算法标签: