Submission #543645

# Submission time Handle Problem Language Result Execution time Memory
543645 2022-03-31T06:38:39 Z tudor Treasure (info1cup19_treasure) C++17
100 / 100
8 ms 884 KB
#include <iostream>

using namespace std;
const int nmax = 2e5;

pair < char, int > st[nmax + 1];
string s;
int sz = 0;

int main() {
    int n, k;

    cin >> n >> k >> s;
    st[sz] = { '#', 1 };
    for ( int i = 0; i < n; i++ ) {
        if ( s[i] != st[sz].first )
            st[++sz] = { s[i], 1 };
        else {
            st[sz].second++;
            if ( st[sz].second == k )
                st[sz--] = { 0, 0 };
        }
    }
    for ( int i = 1; i <= sz; i++ )
        for ( int j = 1; j <= st[i].second; j++ )
            cout << st[i].first;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 3 ms 388 KB Output is correct
21 Correct 4 ms 548 KB Output is correct
22 Correct 5 ms 572 KB Output is correct
23 Correct 3 ms 596 KB Output is correct
24 Correct 5 ms 740 KB Output is correct
25 Correct 4 ms 816 KB Output is correct
26 Correct 7 ms 884 KB Output is correct
27 Correct 8 ms 844 KB Output is correct
28 Correct 7 ms 868 KB Output is correct
29 Correct 7 ms 852 KB Output is correct
30 Correct 6 ms 844 KB Output is correct
31 Correct 6 ms 868 KB Output is correct
32 Correct 6 ms 868 KB Output is correct
33 Correct 6 ms 868 KB Output is correct
34 Correct 7 ms 840 KB Output is correct
35 Correct 6 ms 868 KB Output is correct