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;
stack< pair<int,char> >st;
int main()
{
int n,k;
char ch;
cin>>n>>k;
while(cin>>ch)
{
if(st.empty() || st.top().second!=ch)
st.push({1,ch});
else
{
char a=st.top().second;
int x=st.top().first;
st.pop();
st.push({x+1,a});
}
if(st.top().first==k)
st.pop();
}
string s;
while(!st.empty())
{
for(int i=0;i<st.top().first;i++)
s=st.top().second+s;
st.pop();
}
cout<<s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |