# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1075243 | raduv | Treasure (info1cup19_treasure) | C++17 | 2 ms | 604 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 DEBUG 1
using namespace std;
const int MAXN = 200'000;
int stiva[MAXN + 1][2];
int ns;
int main() {
char ch;
int n, k, i;
scanf("%d%d ", &n, &k);
for( i = 0; i < n; i++ ){
ch = fgetc(stdin);
ch -= 'a';
if(ns > 0 && stiva[ns][0] == ch){
stiva[ns][1]++;
if(stiva[ns][1] == k){
stiva[ns][1] = 0;
stiva[ns][0] = 0;
ns--;
}
}
else{
ns++;
stiva[ns][0] = ch;
stiva[ns][1] = 1;
}
}
for( i = 1; i <= ns; i++ ){
while(stiva[i][1] > 0){
fputc(stiva[i][0] + 'a', stdout);
stiva[i][1]--;
}
}
fputc('\n', stdout);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |