Submission #690888

#TimeUsernameProblemLanguageResultExecution timeMemory
690888MateiKing80Treasure (info1cup19_treasure)C++14
100 / 100
68 ms716 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...