Submission #688642

#TimeUsernameProblemLanguageResultExecution timeMemory
688642divadTreasure (info1cup19_treasure)C++14
100 / 100
5 ms604 KiB
#include <bits/stdc++.h> #define MAX 200002 using namespace std; int n,vf,k; pair<char, int> st[MAX]; char ch; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> ch; pair<char, int> add = {ch, 1}; while(vf >= 1 && st[vf].first == add.first){ add.second += st[vf].second; vf--; } st[++vf] = add; if(st[vf].second >= k){ if(st[vf].second%k == 0){ vf--; }else{ st[vf].second %= k; } } } for(int i = 1; i <= vf; i++){ for(int j = 1; j <= st[i].second; j++){ cout << st[i].first; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...