이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |