#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin>>n>>k;
string s, t = "";
cin>>s;
for(int i=0;i<n;++i) {
t += s[i];
if(t.size() >= k) {
bool ok = true;
for(int j=t.size()-1;j>=t.size()-k;--j) {
if(t.back() != t[j]) {
ok = false;
break;
}
}
if(ok)
t.resize(t.size() - k);
}
}
cout<<t<<'\n';
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |