Official

B - Qual B Editorial by en_translator


A direct implementation as described in the Samples will be accepted.
Specifically, scan the string from the beginning, and replace \((K+1)\)-th and later occurrences of o with x.

Sample code (C++):

#include<bits/stdc++.h>

using namespace std;

int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  for(auto &nx : s){
    if(nx=='o'){
      if(k<=0){nx='x';}
      k--;
    }
  }
  cout << s << "\n";
  return 0;
}

posted:
last update: