# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1208692 | horiaboeriu | Treasure (info1cup19_treasure) | C++20 | 2 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200000
int ap[MAXN];
char v[MAXN];
int main()
{
int n, k, i, vf;
char ch;
scanf("%d%d ", &n, &k);
vf = 0;
v[0] = ap[0] = -1;
for (i = 0; i < n; i++) {
ch = fgetc(stdin);
if (ch == v[vf]) {
ap[vf]++;
} else {
vf++;
ap[vf] = 1;
v[vf] = ch;
}
if (ap[vf] == k) {
vf--;
}
}
for (i = 1; i <= vf; i++) {
for (; ap[i] > 0; ap[i]--) {
fputc(v[i], stdout);
}
}
fputc('\n', stdout);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |