이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* 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 |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |