# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645299 | notme | Treasure (info1cup19_treasure) | C++14 | 5 ms | 864 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>
#define endl '\n'
using namespace std;
const int MAXN = 2e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, k;
char s[MAXN];
int cnt[MAXN];
void solve()
{
cin >> n >> k;
vector < pair < char, int > > v;
for (int i = 1; i <= n; ++ i)
{
cin >> s[i];
if(v.size())
{
if(v.back().first == s[i])
{
v.back().second ++;
v.back().second %= k;
if(v.back().second == 0)v.pop_back();
}
else v.push_back(make_pair(s[i], 1));
}
else v.push_back(make_pair(s[i], 1));
}
for (int i = 0; i < v.size(); ++ i)
{
for (int j = 0; j < v[i].second; ++ j)
cout << v[i].first;
}
cout << endl;
}
int main()
{
speed();
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |