This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 11;
int main(){
int n, k; cin >> n >> k;
string s; cin >> s;
vector<int> eq; eq.push_back(0);
string ans;
char pv = -1;
for(auto c : s){
if(c == pv) eq.push_back(eq.back() + 1);
else eq.push_back(1);
ans.push_back(c);
if(eq.back() >= k){
for(int i = 0; i < k; i++) ans.pop_back(), eq.pop_back();
pv = ans.empty() ? -1 : ans.back();
}else{
pv = c;
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |