Submission #839048

# Submission time Handle Problem Language Result Execution time Memory
839048 2023-08-28T14:37:38 Z fanwen Treasure (info1cup19_treasure) C++17
100 / 100
4 ms 724 KB
/**
 *      author : pham van sam 
 *      created : 28 August 2023 (Monday)
 **/

#include <bits/stdc++.h>

using namespace std;

void you_make_it(void) {
    int n, k; cin >> n >> k;
    vector <pair <char, int>> vt;
    for (int i = 1; i <= n; ++i) {
    	char x; cin >> x;
    	if(!vt.empty() and vt.back().first == x) {
    		vt.back().second++;
    		if(vt.back().second == k) vt.pop_back();
    	} else vt.emplace_back(x, 1);
    }
    for (auto [x, d] : vt) {
    	for (int i = 0; i < d; ++i) cout << x;
    }
}

signed main() {

#ifdef LOCAL
    freopen("TASK.inp", "r", stdin);
    freopen("TASK.out", "w", stdout);
#endif
    auto start_time = chrono::steady_clock::now();

    cin.tie(0), cout.tie(0) -> sync_with_stdio(0);

    you_make_it();

    auto end_time = chrono::steady_clock::now();

    cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl;

    return (0 ^ 0);
}

// Dream it. Wish it. Do it.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 336 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 456 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 3 ms 596 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 4 ms 576 KB Output is correct
27 Correct 3 ms 560 KB Output is correct
28 Correct 3 ms 580 KB Output is correct
29 Correct 3 ms 580 KB Output is correct
30 Correct 3 ms 696 KB Output is correct
31 Correct 3 ms 724 KB Output is correct
32 Correct 3 ms 620 KB Output is correct
33 Correct 3 ms 712 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 3 ms 596 KB Output is correct