Submission #1326526

#TimeUsernameProblemLanguageResultExecution timeMemory
1326526lunarechoTreasure (info1cup19_treasure)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin>>n>>k;
    string s, t = "";
    cin>>s;
    for(int i=0;i<n;++i) {
        t += s[i];
        if(t.size() >= k) {
            bool ok = true;
            for(int j=t.size()-1;j>=t.size()-k;--j) {
                if(t.back() != t[j]) {
                    ok = false;
                    break;
                }
            }
            if(ok)
                t.resize(t.size() - k);
        }
    }
    cout<<t<<'\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...