# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915798 | andrei_iorgulescu | Treasure (info1cup19_treasure) | C++14 | 5 ms | 840 KiB |
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;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin >> n >> k;
stack<pair<char,int>>s;
for (int i = 1; i <= n; i++)
{
char c;
cin >> c;
if (s.empty() == true or s.top().first != c)
s.push({c,1});
else
s.top().second++;
if (s.top().second == k)
s.pop();
}
vector<char>v;
while (!s.empty())
{
for (int i = 1; i <= s.top().second; i++)
v.push_back(s.top().first);
s.pop();
}
reverse(v.begin(),v.end());
for (int i = 0; i < v.size(); i++)
cout << v[i];
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |