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 <iostream>
#include <stack>
#include <vector>
using namespace std;
struct aaa {
char val;
int rep;
};
stack <aaa> s;
vector <char> v;
int main() {
char a;
int n, k, i;
cin >> n >> k;
for ( i = 0; i < n; i++ ) {
cin >> a;
if ( !s.empty() && s.top().val == a ) {
s.top().rep++;
if ( s.top().rep == k )
s.pop();
} else
s.push( { a, 1 } );
}
while ( !s.empty() ) {
for ( i = 0; i < s.top().rep; i++ )
v.push_back( s.top().val );
s.pop();
}
for ( i = v.size() - 1; i >= 0; i-- )
cout << v[i];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |