이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MAX 200002
using namespace std;
int n,vf,k;
pair<char, int> st[MAX];
char ch;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> ch;
pair<char, int> add = {ch, 1};
while(vf >= 1 && st[vf].first == add.first){
add.second += st[vf].second;
vf--;
}
st[++vf] = add;
if(st[vf].second >= k){
if(st[vf].second%k == 0){
vf--;
}else{
st[vf].second %= k;
}
}
}
for(int i = 1; i <= vf; i++){
for(int j = 1; j <= st[i].second; j++){
cout << st[i].first;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |